From 2c1c8bc8de0b12f71152d822c04e939bb6f0a7de Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 19 Feb 2024 23:16:50 +0000 Subject: [PATCH] Work around for listAllAvailablePlugins --- components/misc/osgpluginchecker.cpp.in | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/components/misc/osgpluginchecker.cpp.in b/components/misc/osgpluginchecker.cpp.in index 9bc165c5d6..4b89551206 100644 --- a/components/misc/osgpluginchecker.cpp.in +++ b/components/misc/osgpluginchecker.cpp.in @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include @@ -30,6 +32,31 @@ namespace Misc bool checkRequiredOSGPluginsArePresent() { + // work around osgDB::listAllAvailablePlugins() not working on some platforms due to a suspected OSG bug + std::filesystem::path pluginDirectoryName = std::string("osgPlugins-") + std::string(osgGetVersion()); + osgDB::FilePathList& filepath = osgDB::getLibraryFilePathList(); + for (const auto& path : filepath) + { +#ifdef OSG_USE_UTF8_FILENAME + std::filesystem::path osgPath {stringToU8String(path)}; +#else + std::filesystem::path osgPath {path}; +#endif + if (!osgPath.has_filename()) + osgPath = osgPath.parent_path(); + + if (osgPath.filename() == pluginDirectoryName) + { + osgPath = osgPath.parent_path(); +#ifdef OSG_USE_UTF8_FILENAME + std::string extraPath = u8StringToString(osgPath.u8string_view()); +#else + std::string extraPath = osgPath.string(); +#endif + filepath.emplace_back(std::move(extraPath)); + } + } + auto availableOSGPlugins = osgDB::listAllAvailablePlugins(); bool haveAllPlugins = true; for (std::string_view plugin : USED_OSG_PLUGIN_FILENAMES)