From f485ea11f25299f4071b8a85c91af220492ecefb Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Wed, 29 Nov 2017 20:51:20 +0000 Subject: [PATCH] Simplify library loading code. Removed many unused methods that cluttered up the implementation. Refs #0 --- Framework/Kernel/CMakeLists.txt | 1 + Framework/Kernel/inc/MantidKernel/DllOpen.h | 38 +--- .../Kernel/inc/MantidKernel/LibraryManager.h | 18 +- .../Kernel/inc/MantidKernel/LibraryWrapper.h | 11 +- Framework/Kernel/src/DllOpen.cpp | 174 ++++-------------- Framework/Kernel/src/LibraryManager.cpp | 107 ++++++----- Framework/Kernel/src/LibraryWrapper.cpp | 46 ++--- Framework/Kernel/test/DllOpenTest.h | 45 +++++ qt/widgets/common/src/PluginLibraries.cpp | 4 +- 9 files changed, 188 insertions(+), 256 deletions(-) create mode 100644 Framework/Kernel/test/DllOpenTest.h diff --git a/Framework/Kernel/CMakeLists.txt b/Framework/Kernel/CMakeLists.txt index 43e22e7a928..60d71349dcb 100644 --- a/Framework/Kernel/CMakeLists.txt +++ b/Framework/Kernel/CMakeLists.txt @@ -344,6 +344,7 @@ set ( TEST_FILES DirectoryValidatorTest.h DiskBufferISaveableTest.h DiskBufferTest.h + DllOpenTest.h DynamicFactoryTest.h EigenConversionHelpersTest.h EnabledWhenPropertyTest.h diff --git a/Framework/Kernel/inc/MantidKernel/DllOpen.h b/Framework/Kernel/inc/MantidKernel/DllOpen.h index 888c8ce09d3..9ddd31da5c5 100644 --- a/Framework/Kernel/inc/MantidKernel/DllOpen.h +++ b/Framework/Kernel/inc/MantidKernel/DllOpen.h @@ -46,46 +46,16 @@ public: ~DllOpen() = delete; public: - /// Static method for opening the shared library - static void *openDll(const std::string &); + /// Check if the filename conforms to the expected style for this platform + static bool isValidFilename(const std::string &filename); /// Static method for opening the shared library - static void *openDll(const std::string &, const std::string &); - - /// Static method for retrieving a function pointer - static void *getFunction(void *, const std::string &); + static void *openDll(const std::string &filepath); /// Static method for closing the shared library - static void closeDll(void *); - - /// Static method for converting a filename to a libName (without lib___.so or - /// ___.dll) - static const std::string convertToLibName(std::string); - - /// Adds a directiry to the dll search path. - static void addSearchDirectory(const std::string &); + static void closeDll(void *handle); private: - // private functions specific to implementation - /// Implementation specifc static method for opening a shared library - static void *openDllImpl(const std::string &); - - /// Implementation specifc static method for retrieving a function pointer - static void *getFunctionImpl(void *, const std::string &); - - /// Implementation specifc static method for closing a shared library - static void closeDllImpl(void *); - - /// Implementation specifc static method for adding a directiry to the dll - /// search path. - static void addSearchDirectoryImpl(const std::string &); - - /// lib prefix - static const std::string LIB_PREFIX; - /// lib postfix - static const std::string LIB_POSTFIX; - /// path seperator - static const std::string PATH_SEPERATOR; }; } // namespace Kernel diff --git a/Framework/Kernel/inc/MantidKernel/LibraryManager.h b/Framework/Kernel/inc/MantidKernel/LibraryManager.h index 447863e16de..d8bb2acee8e 100644 --- a/Framework/Kernel/inc/MantidKernel/LibraryManager.h +++ b/Framework/Kernel/inc/MantidKernel/LibraryManager.h @@ -48,7 +48,7 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class MANTID_KERNEL_DLL LibraryManagerImpl { public: enum LoadLibraries { Recursive, NonRecursive }; - int openLibraries(const std::string &, LoadLibraries loadingBehaviour, + int openLibraries(const std::string &libpath, LoadLibraries loadingBehaviour, const std::vector<std::string> &excludes); LibraryManagerImpl(const LibraryManagerImpl &) = delete; LibraryManagerImpl &operator=(const LibraryManagerImpl &) = delete; @@ -63,13 +63,19 @@ private: /// Load libraries from the given Poco::File path /// Private so Poco::File doesn't leak to the public interface - int openLibraries(const Poco::File &, LoadLibraries loadingBehaviour, + int openLibraries(const Poco::File &libpath, LoadLibraries loadingBehaviour, const std::vector<std::string> &excludes); + /// Check if the library should be loaded + bool shouldBeLoaded(const std::string &filename, + const std::vector<std::string> &excludes) const; + /// Check if the library has already been loaded + bool isLoaded(const std::string &filename) const; + /// Returns true if the library has been requested to be excluded + bool isExcluded(const std::string &filename, + const std::vector<std::string> &excludes) const; /// Load a given library - bool loadLibrary(Poco::Path filepath); - /// Returns true if the library is to be loaded - bool skipLibrary(const std::string &filename, - const std::vector<std::string> &excludes); + int openLibrary(const Poco::File &filepath, const std::string &cacheKey); + /// Storage for the LibraryWrappers. std::unordered_map<std::string, LibraryWrapper> m_openedLibs; }; diff --git a/Framework/Kernel/inc/MantidKernel/LibraryWrapper.h b/Framework/Kernel/inc/MantidKernel/LibraryWrapper.h index 102c01e3034..3bfa68cac7f 100644 --- a/Framework/Kernel/inc/MantidKernel/LibraryWrapper.h +++ b/Framework/Kernel/inc/MantidKernel/LibraryWrapper.h @@ -41,14 +41,15 @@ public: // Move-only class. The internal module pointer // is not safe to copy around. LibraryWrapper() = default; + // No copy LibraryWrapper(const LibraryWrapper &) = delete; - LibraryWrapper& operator=(const LibraryWrapper &) = delete; - LibraryWrapper(LibraryWrapper &&) = default; - LibraryWrapper& operator=(LibraryWrapper &&) = default; + LibraryWrapper &operator=(const LibraryWrapper &) = delete; + + LibraryWrapper(LibraryWrapper &&src); + LibraryWrapper &operator=(LibraryWrapper &&rhs); ~LibraryWrapper(); - bool openLibrary(const std::string &); - bool openLibrary(const std::string &, const std::string &); + bool openLibrary(const std::string &filepath); private: /** An untyped pointer to the loaded library. diff --git a/Framework/Kernel/src/DllOpen.cpp b/Framework/Kernel/src/DllOpen.cpp index 1bd92c47838..2b514b89d44 100644 --- a/Framework/Kernel/src/DllOpen.cpp +++ b/Framework/Kernel/src/DllOpen.cpp @@ -1,11 +1,6 @@ -/* - If the OS is Windows then LoadLibrary, GetProcAddress and FreeLibrary are used. - Some casting to HINSTANCE is required. - Shared library name is of the form *.dll. - - If the OS is Linux then dlopen, dlsym and dlclose are used. - Shared library name is of the form lib*.so. -*/ +#include "MantidKernel/DllOpen.h" +#include "MantidKernel/Logger.h" + #if _WIN32 #define _WIN32_WINNT 0x0510 #include <windows.h> @@ -13,8 +8,7 @@ #include <dlfcn.h> #endif /* _WIN32 */ -#include "MantidKernel/DllOpen.h" -#include "MantidKernel/Logger.h" +#include <boost/algorithm/string/predicate.hpp> #include <string> @@ -26,91 +20,27 @@ namespace { Logger g_log("DllOpen"); } -/* Opens the shared library after appending the required formatting, - * i.e. libName.so for Linux and Name.dll for Windows. - * Calls the correct implementation based on the current O/S. - * @param libName :: Name of the library. - * @return Pointer to library (of type void). - **/ -void *DllOpen::openDll(const std::string &libName) { - std::string str = LIB_PREFIX + libName + LIB_POSTFIX; - return openDllImpl(str); -} - -/* Opens the shared library after appending the required formatting, - * i.e. libName.so for Linux and Name.dll for Windows. - * Calls the correct implementation based on the current O/S. - * @param libName :: Name of the library. - * @param filePath :: The location on the library. - * @return Pointer to library (of type void). - **/ -void *DllOpen::openDll(const std::string &libName, - const std::string &filePath) { - std::string str = - filePath + PATH_SEPERATOR + LIB_PREFIX + libName + LIB_POSTFIX; - return openDllImpl(str); -} - -/* Retrieves a function from the opened library. - * Calls the correct implementation based on the current O/S. - * @param libName :: Name of the library. - * @param funcName :: The name of the function to retrieve. - * @return Pointer to the function (of type void). - **/ -void *DllOpen::getFunction(void *libName, const std::string &funcName) { - return getFunctionImpl(libName, funcName); -} +// ----------------------------------------------------------------------------- +// Windows-specific implementations +// ----------------------------------------------------------------------------- +#if defined(_WIN32) -/* Closes an open library. - * Calls the correct implementation based on the current O/S. - * @param libName :: Name of the library. - **/ -void DllOpen::closeDll(void *libName) { closeDllImpl(libName); } +const std::string LIB_SUFFIX = ".dll"; -/** Converts a file name (without directory) to a undecorated library name. - * e.g. MyLibrary.dll or libMyLibary.so would become MyLibrary. - * @param fileName :: The filename (with extension) to convert - * @return The converted libName, or empty string if the conversion was not - *possible. - **/ -const std::string DllOpen::convertToLibName(std::string fileName) { - if ((fileName.compare(0, LIB_PREFIX.size(), LIB_PREFIX) == 0) && - (fileName.find(PATH_SEPERATOR) == std::string::npos)) { - // found - fileName = - fileName.substr(LIB_PREFIX.size(), fileName.size() - LIB_PREFIX.size()); - } else { - // prefix not found - return ""; - } - std::string::size_type pos = fileName.rfind(LIB_POSTFIX); - if (pos != std::string::npos && - pos == (fileName.size() - LIB_POSTFIX.size())) { - // found - fileName = fileName.substr(0, fileName.size() - LIB_POSTFIX.size()); - } else { - // postfix not found - return ""; - } - return fileName; -} - -/* Adds a directory to the dll cearch path - **/ -void DllOpen::addSearchDirectory(const std::string &dir) { - addSearchDirectoryImpl(dir); +/** + * Does the file have the expected form for this platform + * @param filename The file name of the library + * @return True if it matches the expected format, false otherwise + */ +bool DllOpen::isValidFilename(const std::string &filename) { + return boost::ends_with(filename, LIB_SUFFIX); } -#if _WIN32 -const std::string DllOpen::LIB_PREFIX = ""; -const std::string DllOpen::LIB_POSTFIX = ".dll"; -const std::string DllOpen::PATH_SEPERATOR = "\\"; - /* Opens the Windows .dll file. * @param filePath :: Filepath of the library. * @return Pointer to library (of type void). **/ -void *DllOpen::OpenDllImpl(const std::string &filePath) { +void *DllOpen::openDll(const std::string &filePath) { void *handle = LoadLibrary(filePath.c_str()); if (!handle) { @@ -138,75 +68,49 @@ void *DllOpen::OpenDllImpl(const std::string &filePath) { return handle; } -/* Retrieves a function from the opened .dll file. - * Only works if the function has been declared as extern 'C'. - * @param libName :: Name of the library. - * @param funcName :: The name of the function to retrieve. - * @return Pointer to the function (of type void). - **/ -void *DllOpen::GetFunctionImpl(void *libName, const std::string &funcName) { - return (void *)GetProcAddress((HINSTANCE)libName, funcName.c_str()); -} - /* Closes an open .dll file. - * @param libName :: Name of the library. + * @param handle :: A handle to the open library. **/ -void DllOpen::CloseDllImpl(void *libName) { FreeLibrary((HINSTANCE)libName); } - -/* Adds a directory to the dll search path - **/ -void DllOpen::addSearchDirectoryImpl(const std::string &dir) { - SetDllDirectory(dir.c_str()); -} +void DllOpen::closeDll(void *handle) { FreeLibrary((HINSTANCE)handle); } #else -const std::string DllOpen::LIB_PREFIX = "lib"; -// Shared libraries end in "so" on linux, "dylib" on the Mac +const std::string LIB_PREFIX = "lib"; #ifdef __linux__ -const std::string DllOpen::LIB_POSTFIX = ".so"; +const std::string LIB_SUFFIX = ".so"; #elif defined __APPLE__ -const std::string DllOpen::LIB_POSTFIX = ".dylib"; +const std::string LIB_SUFFIX = ".dylib"; #endif -const std::string DllOpen::PATH_SEPERATOR = "/"; +/** + * Does the file have the expected form for this platform + * @param filename The file name of the library + * @return True if it matches the expected format, false otherwise + */ +bool DllOpen::isValidFilename(const std::string &filename) { + return boost::starts_with(filename, LIB_PREFIX) && + boost::ends_with(filename, LIB_SUFFIX); +} /* Opens the Linux .so file * @param filePath :: Filepath of the library. * @return Pointer to library (of type void). **/ -void *DllOpen::openDllImpl(const std::string &filePath) { - void *handle = dlopen(filePath.c_str(), RTLD_NOW | RTLD_GLOBAL); +void *DllOpen::openDll(const std::string &filepath) { + void *handle = dlopen(filepath.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!handle) { - g_log.error("Could not open library " + filePath + ": " + dlerror()); + g_log.error("Could not open library " + filepath + ": " + dlerror()); } return handle; } -/* Retrieves a function from the opened library. - * Only works if the function has been declared as extern 'C'. - * @param libName :: Name of the library. - * @param funcName :: The name of the function to retrieve. - * @return Pointer to the function (of type void). - **/ -void *DllOpen::getFunctionImpl(void *libName, const std::string &funcName) { - return dlsym(libName, funcName.c_str()); -} - /* Closes an open .so file. - * @param libName :: Name of the library. + * @param handle :: A handle to the open library. **/ -void DllOpen::closeDllImpl(void *libName) { - UNUSED_ARG(libName); - // Commented out for now due to a potential bug in glibc - // dlclose(libName); -} - -/* Adds a directory to the dll search path - * @param dir Unused argument - */ -void DllOpen::addSearchDirectoryImpl(const std::string &dir) { - UNUSED_ARG(dir); +void DllOpen::closeDll(void *handle) { + UNUSED_ARG(handle); + // A bug in glibc prevents us from calling this. + // dlclose(handle); } #endif /* _WIN32 */ diff --git a/Framework/Kernel/src/LibraryManager.cpp b/Framework/Kernel/src/LibraryManager.cpp index 5cb0941f32c..a6160a0b0ab 100644 --- a/Framework/Kernel/src/LibraryManager.cpp +++ b/Framework/Kernel/src/LibraryManager.cpp @@ -18,12 +18,12 @@ Logger g_log("LibraryManager"); /// Constructor LibraryManagerImpl::LibraryManagerImpl() : m_openedLibs() { - g_log.debug() << "LibraryManager created.\n"; + g_log.debug("LibraryManager created."); } /** * Opens suitable DLLs on a given path. - * @param filePath The filepath to the directory where the libraries are. + * @param filepath The filepath to the directory where the libraries are. * @param loadingBehaviour Control how libraries are searched for * @param excludes If not empty then each string is considered as a substring * to search within each library to be opened. If the substring is found then @@ -31,17 +31,17 @@ LibraryManagerImpl::LibraryManagerImpl() : m_openedLibs() { * @return The number of libraries opened. */ int LibraryManagerImpl::openLibraries( - const std::string &filePath, LoadLibraries loadingBehaviour, + const std::string &filepath, LoadLibraries loadingBehaviour, const std::vector<std::string> &excludes) { - g_log.debug() << "Opening all libraries in " << filePath << "\n"; + g_log.debug("Opening all libraries in " + filepath + "\n"); try { - return openLibraries(Poco::File(filePath), loadingBehaviour, excludes); + return openLibraries(Poco::File(filepath), loadingBehaviour, excludes); } catch (std::exception &exc) { g_log.debug() << "Error occurred while opening libraries: " << exc.what() << "\n"; return 0; } catch (...) { - g_log.error() << "An unknown error occurred while opening libraries."; + g_log.error("An unknown error occurred while opening libraries."); return 0; } } @@ -51,7 +51,7 @@ int LibraryManagerImpl::openLibraries( //------------------------------------------------------------------------- /** * Opens suitable DLLs on a given path. - * @param filePath A Poco::File object pointing to a directory where the + * @param libpath A Poco::File object pointing to a directory where the * libraries are. * @param loadingBehaviour Control how libraries are searched for * @param excludes If not empty then each string is considered as a substring @@ -60,86 +60,97 @@ int LibraryManagerImpl::openLibraries( * @return The number of libraries opened. */ int LibraryManagerImpl::openLibraries( - const Poco::File &libPath, + const Poco::File &libpath, LibraryManagerImpl::LoadLibraries loadingBehaviour, const std::vector<std::string> &excludes) { int libCount(0); - if (libPath.exists() && libPath.isDirectory()) { - DllOpen::addSearchDirectory(libPath.path()); + if (libpath.exists() && libpath.isDirectory()) { // Iterate over the available files Poco::DirectoryIterator end_itr; - for (Poco::DirectoryIterator itr(libPath); itr != end_itr; ++itr) { + for (Poco::DirectoryIterator itr(libpath); itr != end_itr; ++itr) { const Poco::File &item = *itr; if (item.isFile()) { - if (skipLibrary(itr.path().getFileName(), excludes)) + if (shouldBeLoaded(itr.path().getFileName(), excludes)) + libCount += openLibrary(itr.path(), itr.path().getFileName()); + else continue; - if (loadLibrary(itr.path())) { - ++libCount; - } } else if (loadingBehaviour == LoadLibraries::Recursive) { // it must be a directory libCount += openLibraries(item, LoadLibraries::Recursive, excludes); } } } else { - g_log.error("In OpenAllLibraries: " + libPath.path() + + g_log.error("In OpenAllLibraries: " + libpath.path() + " must be a directory."); } return libCount; } +/** + * Check if the library should be loaded + * @param filename The filename of the library, i.e no directory + * @param excludes If not empty then each string is considered as a substring + * to search within each library to be opened. If the substring is found then + * the library is not opened. + * @return True if loading should be attempted + */ +bool LibraryManagerImpl::shouldBeLoaded( + const std::string &filename, + const std::vector<std::string> &excludes) const { + return !isLoaded(filename) && DllOpen::isValidFilename(filename) && + !isExcluded(filename, excludes); +} + +/** + * Check if the library been loaded already? + * @param filename The filename of the library, i.e no directory + * @return True if the library has been seen before + */ +bool LibraryManagerImpl::isLoaded(const std::string &filename) const { + return m_openedLibs.find(filename) != m_openedLibs.cend(); +} + /** * Returns true if the name contains one of the strings given in the * exclude list. Each string from the variable is * searched for with the filename so an exact match is not necessary. This * avoids having to specify prefixes and suffixes for different platforms, * i.e. 'plugins.exclude = MantidKernel' will exclude libMantidKernel.so - * @param filename A string giving the filename/file path + * @param filename The filename of the library (no directory) * @param excludes A list of substrings to exclude library from loading * @return True if the library should be skipped */ -bool LibraryManagerImpl::skipLibrary(const std::string &filename, - const std::vector<std::string> &excludes) { - bool skipme(false); +bool LibraryManagerImpl::isExcluded( + const std::string &filename, + const std::vector<std::string> &excludes) const { for (const auto &exclude : excludes) { if (filename.find(exclude) != std::string::npos) { - skipme = true; - break; + return true; } } - return skipme; + return false; } /** * Load a library * @param filepath :: A Poco::File The full path to a library as a string +* @param cacheKey :: An identifier for the cache if loading is successful +* @return 1 if the file loaded successfully, 0 otherwise */ -bool LibraryManagerImpl::loadLibrary(Poco::Path filepath) { - // Get the name of the library. - std::string libName = DllOpen::convertToLibName(filepath.getFileName()); - if (libName.empty()) - return false; - // Check that a library with this name has not already been loaded - if (m_openedLibs.find(boost::algorithm::to_lower_copy(libName)) == - m_openedLibs.end()) { - filepath.makeParent(); - // Try to open the library. The wrapper will unload the library when it - // is deleted - LibraryWrapper dlwrap; - if (dlwrap.openLibrary(libName, filepath.toString())) { - // Successfully opened, so add to map - if (g_log.is(Poco::Message::PRIO_DEBUG)) { - g_log.debug("Opened library: " + libName + ".\n"); - } - m_openedLibs.emplace(libName, std::move(dlwrap)); - return true; - } else { - return false; +int LibraryManagerImpl::openLibrary(const Poco::File &filepath, + const std::string &cacheKey) { + // Try to open the library. The wrapper will unload the library when it + // is deleted + LibraryWrapper dlwrap; + if (dlwrap.openLibrary(filepath.path())) { + // Successfully opened, so add to map + if (g_log.is(Poco::Message::PRIO_DEBUG)) { + g_log.debug("Opened library: " + filepath.path() + ".\n"); } - } else { - g_log.debug() << libName << " already opened, skipping load\n"; - } - return false; + m_openedLibs.emplace(cacheKey, std::move(dlwrap)); + return 1; + } else + return 0; } } // namespace Kernel diff --git a/Framework/Kernel/src/LibraryWrapper.cpp b/Framework/Kernel/src/LibraryWrapper.cpp index cc10a72de35..1dca81052b2 100644 --- a/Framework/Kernel/src/LibraryWrapper.cpp +++ b/Framework/Kernel/src/LibraryWrapper.cpp @@ -1,9 +1,25 @@ -#include "MantidKernel/DllOpen.h" #include "MantidKernel/LibraryWrapper.h" +#include "MantidKernel/DllOpen.h" namespace Mantid { namespace Kernel { +/** + * Move constructor + * @param src Constructor from this temporary + */ +LibraryWrapper::LibraryWrapper(LibraryWrapper &&src) { *this = std::move(src); } + +/** + * Move assignment + * @param rhs Temporary object as source of assignment + */ +LibraryWrapper &LibraryWrapper::operator=(LibraryWrapper &&rhs) { + using std::swap; + swap(m_module, rhs.m_module); + return *this; +} + /// Destructor LibraryWrapper::~LibraryWrapper() { // Close lib @@ -14,39 +30,17 @@ LibraryWrapper::~LibraryWrapper() { } /** Opens a DLL. - * @param libName :: The name of the file to open (not including the - * lib/so/dll). - * @return True if DLL is opened or already open. - */ -bool LibraryWrapper::openLibrary(const std::string &libName) { - if (!m_module) { - // Load dynamically loaded library - m_module = DllOpen::openDll(libName); - - if (!m_module) { - return false; - } - } - - return true; -} - -/** Opens a DLL. - * @param libName :: The name of the file to open (not including the - * lib/so/dll). - * @param filePath :: The filepath to the directory where the library is. + * @param filepath :: The filepath to the directory where the library is. * @return True if DLL is opened or already open */ -bool LibraryWrapper::openLibrary(const std::string &libName, - const std::string &filePath) { +bool LibraryWrapper::openLibrary(const std::string &filepath) { if (!m_module) { // Load dynamically loaded library - m_module = DllOpen::openDll(libName, filePath); + m_module = DllOpen::openDll(filepath); if (!m_module) { return false; } } - return true; } diff --git a/Framework/Kernel/test/DllOpenTest.h b/Framework/Kernel/test/DllOpenTest.h new file mode 100644 index 00000000000..da9cd86ddb5 --- /dev/null +++ b/Framework/Kernel/test/DllOpenTest.h @@ -0,0 +1,45 @@ +#ifndef MANTID_KERNEL_DLLOPENTEST_H +#define MANTID_KERNEL_DLLOPENTEST_H + +#include "MantidKernel/DllOpen.h" +#include <cxxtest/TestSuite.h> + +using Mantid::Kernel::DllOpen; + +class DllOpenTest : public CxxTest::TestSuite { + +public: + static DllOpenTest *createSuite() { return new DllOpenTest(); } + static void destroySuite(DllOpenTest *suite) { delete suite; } + + void test_isValidFilename_Returns_True_For_Valid_File() { +#if defined(_WIN32) + TS_ASSERT(DllOpen::isValidFilename("MyLibrary.dll")); +#elif defined(__APPLE__) + TS_ASSERT(DllOpen::isValidFilename("libMyLibrary.dylib")); +#else + TS_ASSERT(DllOpen::isValidFilename("libMyLibrary.so")); +#endif + } + + void test_isValidFilename_Returns_False_For_Invalid_File() { + TS_ASSERT(!DllOpen::isValidFilename("MyLibrary")); + TS_ASSERT(!DllOpen::isValidFilename("MyLibrary.")); +#if defined(_WIN32) + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.so")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.dylib")); + TS_ASSERT(!DllOpen::isValidFilename("MyLibrary.dl")); +#elif defined(__APPLE__) + TS_ASSERT(!DllOpen::isValidFilename("MyLibrary.dll")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.so")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.dyli")); +#else + TS_ASSERT(!DllOpen::isValidFilename("MyLibrary.so")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.dll")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.dylib")); + TS_ASSERT(!DllOpen::isValidFilename("libMyLibrary.s")); +#endif + } +}; + +#endif // MANTID_KERNEL_DLLOPENTEST_H diff --git a/qt/widgets/common/src/PluginLibraries.cpp b/qt/widgets/common/src/PluginLibraries.cpp index 8d0bb059ea9..bf836c4e9f1 100644 --- a/qt/widgets/common/src/PluginLibraries.cpp +++ b/qt/widgets/common/src/PluginLibraries.cpp @@ -45,8 +45,8 @@ int loadPluginsFromCfgPath(std::string key) { * @return The number of libraries successfully loaded */ int loadPluginsFromPath(std::string path) { - // We must *NOT* load plugins compiled against a different version of Qt - // so we set exclude flags by Qt version. +// We must *NOT* load plugins compiled against a different version of Qt +// so we set exclude flags by Qt version. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) static std::vector<std::string> excludes{"Qt5"}; #else -- GitLab