mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
impr: Further improve interfacing with external plugins
This commit is contained in:
@@ -159,10 +159,13 @@ namespace hex::init {
|
||||
|
||||
bool loadPlugins() {
|
||||
// Load all plugins
|
||||
bool hasExtraPluginFolders = !PluginManager::getPluginLoadPaths().empty();
|
||||
#if !defined(IMHEX_STATIC_LINK_PLUGINS)
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Plugins)) {
|
||||
PluginManager::load(dir);
|
||||
PluginManager::addLoadPath(dir);
|
||||
}
|
||||
|
||||
PluginManager::load();
|
||||
#endif
|
||||
|
||||
// Get loaded plugins
|
||||
@@ -176,7 +179,7 @@ namespace hex::init {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto shouldLoadPlugin = [executablePath = wolv::io::fs::getExecutablePath()](const Plugin &plugin) {
|
||||
const auto shouldLoadPlugin = [hasExtraPluginFolders, executablePath = wolv::io::fs::getExecutablePath()](const Plugin &plugin) {
|
||||
// In debug builds, ignore all plugins that are not part of the executable directory
|
||||
#if !defined(DEBUG)
|
||||
return true;
|
||||
@@ -185,6 +188,9 @@ namespace hex::init {
|
||||
if (!executablePath.has_value())
|
||||
return true;
|
||||
|
||||
if (hasExtraPluginFolders)
|
||||
return true;
|
||||
|
||||
// Check if the plugin is somewhere in the same directory tree as the executable
|
||||
return !std::fs::relative(plugin.getPath(), executablePath->parent_path()).string().starts_with("..");
|
||||
};
|
||||
@@ -276,6 +282,7 @@ namespace hex::init {
|
||||
|
||||
bool unloadPlugins() {
|
||||
PluginManager::unload();
|
||||
PluginManager::getPluginLoadPaths().clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user