From ddd33c609096570f6b2ca56f83052c47575a3e07 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 24 Sep 2012 09:52:35 +0200 Subject: [PATCH] Fixed: OVQT plugins loading under Unices (in the order: local, OVQT plugins, system) --- .../tools/3d/object_viewer_qt/CMakeLists.txt | 2 +- .../src/extension_system/plugin_spec.cpp | 45 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/CMakeLists.txt index b87416280..41896e9c5 100644 --- a/code/nel/tools/3d/object_viewer_qt/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/CMakeLists.txt @@ -13,7 +13,7 @@ ELSEIF(APPLE) SET(OVQT_PLUGIN_DIR "plugins") ELSE(WIN32) SET(OVQT_PLUGIN_DIR ${NL_SHARE_PREFIX}/object_viewer_qt/plugins) - ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_ABSOLUTE_PREFIX}/object_viewer_qt/\\"") + ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_ABSOLUTE_PREFIX}/object_viewer_qt\\"" -DPLUGINS_DIR="\\"${NL_LIB_ABSOLUTE_PREFIX}/object_viewer_qt\\"") ENDIF(WIN32) IF(UNIX AND WITH_STATIC) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp index f45eae4a1..f24cbcfb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + namespace ExtensionSystem { const char *const PLUGIN_SPEC_NAME = "name"; @@ -143,9 +147,44 @@ bool PluginSpec::setFileName(const QString &fileName) m_fileName = m_prefix + fileName + m_suffix; m_filePath = m_location + "/" + m_fileName; + QFile file; + file.setFileName(m_filePath); + + bool exists = file.exists(); + +#ifdef NL_OS_UNIX + +#ifdef PLUGINS_DIR + if (!exists) + { + // if plugin can't be found in the same directory as spec file, + // looks for it in PLUGINS_DIR + m_filePath = QString("%1/%2").arg(PLUGINS_DIR).arg(m_fileName); + + file.setFileName(m_filePath); + + exists = file.exists(); + } +#endif + +#ifdef NL_LIB_PREFIX + if (!exists) + { + // if plugin can't be found in the same directory as spec file or PLUGINS_DIR, + // looks for it in NL_LIB_PREFIX + m_filePath = QString("%1/%2").arg(NL_LIB_PREFIX).arg(m_fileName); + + file.setFileName(m_filePath); + + exists = file.exists(); + } +#endif + +#endif + nlinfo(m_filePath.toStdString().c_str()); - QFile file(m_filePath); - if (!file.exists()) + + if (!exists) return reportError(QCoreApplication::translate("PluginSpec", "File does not exist: %1").arg(file.fileName())); if (!file.open(QIODevice::ReadOnly)) return reportError(QCoreApplication::translate("PluginSpec", "Could not open file for read: %1").arg(file.fileName())); @@ -391,4 +430,4 @@ bool PluginSpec::reportError(const QString &err) return false; } -} // namespace ExtensionSystem \ No newline at end of file +} // namespace ExtensionSystem