Don't unload/remove plugins immediately, instead require a restart to prevent unclean unload/crash
This commit is contained in:
parent
6f55f0e0c0
commit
17ad77f07a
2 changed files with 39 additions and 7 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -235,12 +235,17 @@ void Ui::OpenRGBPluginsPage::on_RemovePluginButton_clicked()
|
|||
if((plugin_settings["plugins"][plugin_idx]["name"] == entries[cur_row]->ui->NameValue->text().toStdString())
|
||||
&&(plugin_settings["plugins"][plugin_idx]["description"] == entries[cur_row]->ui->DescriptionValue->text().toStdString()))
|
||||
{
|
||||
plugin_settings["plugins"].erase(plugin_idx);
|
||||
/*-----------------------------------------------------*\
|
||||
| Mark plugin to be removed on next restart |
|
||||
\*-----------------------------------------------------*/
|
||||
plugin_settings["plugins_remove"][plugin_settings["plugins_remove"].size()] = entries[cur_row]->ui->PathValue->text().toStdString();
|
||||
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
|
||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||
|
||||
break;
|
||||
QMessageBox::information(this, tr("Restart Needed"), tr("The plugin will be fully removed after restarting OpenRGB."), QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue