mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-29 02:04:13 -04:00
Don't unload/remove plugins immediately, instead require a restart to prevent unclean unload/crash
This commit is contained in:
@@ -127,6 +127,38 @@ void PluginManager::AddPlugin(const filesystem::path& path, bool is_system)
|
||||
|
||||
unsigned int plugin_idx;
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Open plugin settings |
|
||||
\*---------------------------------------------------------------------*/
|
||||
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Check if this plugin is on the remove list |
|
||||
\*---------------------------------------------------------------------*/
|
||||
if(plugin_settings.contains("plugins_remove"))
|
||||
{
|
||||
for(unsigned int plugin_remove_idx = 0; plugin_remove_idx < plugin_settings["plugins_remove"].size(); plugin_remove_idx++)
|
||||
{
|
||||
LOG_WARNING("[PluginManager] Checking remove %d, %s", plugin_remove_idx, to_string(plugin_settings["plugins_remove"][plugin_remove_idx]).c_str());
|
||||
|
||||
if(plugin_settings["plugins_remove"][plugin_remove_idx] == path.generic_u8string())
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the plugin file |
|
||||
\*---------------------------------------------------------*/
|
||||
filesystem::remove(path);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Erase the plugin from the remove list |
|
||||
\*-----------------------------------------------------------------*/
|
||||
plugin_settings["plugins_remove"].erase(plugin_remove_idx);
|
||||
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
|
||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Search active plugins to see if this path already exists |
|
||||
\*---------------------------------------------------------------------*/
|
||||
@@ -182,11 +214,6 @@ void PluginManager::AddPlugin(const filesystem::path& path, bool is_system)
|
||||
bool found = false;
|
||||
unsigned int plugin_ct = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Open plugin list and check if plugin is in the list |
|
||||
\*-----------------------------------------------------*/
|
||||
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
|
||||
|
||||
if(plugin_settings.contains("plugins"))
|
||||
{
|
||||
plugin_ct = (unsigned int)plugin_settings["plugins"].size();
|
||||
|
||||
Reference in New Issue
Block a user