Always overwrite file when updating plugins, add additional logging to plugin management
This commit is contained in:
parent
41389f4746
commit
b2c6028cb8
2 changed files with 18 additions and 3 deletions
|
|
@ -44,6 +44,7 @@ void PluginManager::ScanAndLoadPlugins()
|
||||||
|
|
||||||
for(int i = 0; i < QDir(plugins_dir).entryList(QDir::Files).size(); i++)
|
for(int i = 0; i < QDir(plugins_dir).entryList(QDir::Files).size(); i++)
|
||||||
{
|
{
|
||||||
|
LOG_TRACE("[PluginManager] Found plugin file %s", QDir(plugins_dir).entryList(QDir::Files)[i].toStdString().c_str());
|
||||||
FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString());
|
FileList.push_back(QDir(plugins_dir).entryList(QDir::Files)[i].toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,6 +98,8 @@ void PluginManager::AddPlugin(std::string path)
|
||||||
{
|
{
|
||||||
if(plugin->GetPluginAPIVersion() == OPENRGB_PLUGIN_API_VERSION)
|
if(plugin->GetPluginAPIVersion() == OPENRGB_PLUGIN_API_VERSION)
|
||||||
{
|
{
|
||||||
|
LOG_TRACE("[PluginManager] Plugin %s has a compatible API version", path.c_str());
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Get the plugin information |
|
| Get the plugin information |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
|
|
@ -184,6 +187,11 @@ void PluginManager::AddPlugin(std::string path)
|
||||||
LoadPlugin(path);
|
LoadPlugin(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loader->unload();
|
||||||
|
LOG_WARNING("[PluginManager] Plugin %s has an incompatible API version", path.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -193,6 +201,8 @@ void PluginManager::RemovePlugin(std::string path)
|
||||||
{
|
{
|
||||||
unsigned int plugin_idx;
|
unsigned int plugin_idx;
|
||||||
|
|
||||||
|
LOG_TRACE("[PluginManager] Attempting to remove plugin %s", path.c_str());
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------*\
|
||||||
| Search active plugins to see if this path already exists |
|
| Search active plugins to see if this path already exists |
|
||||||
\*---------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------*/
|
||||||
|
|
@ -209,6 +219,7 @@ void PluginManager::RemovePlugin(std::string path)
|
||||||
\*---------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------*/
|
||||||
if(plugin_idx == ActivePlugins.size())
|
if(plugin_idx == ActivePlugins.size())
|
||||||
{
|
{
|
||||||
|
LOG_TRACE("[PluginManager] Plugin %s not active", path.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,6 +228,7 @@ void PluginManager::RemovePlugin(std::string path)
|
||||||
\*---------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------*/
|
||||||
if(ActivePlugins[plugin_idx].loaded)
|
if(ActivePlugins[plugin_idx].loaded)
|
||||||
{
|
{
|
||||||
|
LOG_TRACE("[PluginManager] Plugin %s is active, unloading", path.c_str());
|
||||||
UnloadPlugin(path);
|
UnloadPlugin(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
||||||
std::string to_file = to_path + filesystem::path(from_path).filename().string();
|
std::string to_file = to_path + filesystem::path(from_path).filename().string();
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
|
||||||
|
LOG_TRACE("[OpenRGBPluginsPage] Installing plugin %s", install_file.c_str());
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Check if a plugin with this path already exists |
|
| Check if a plugin with this path already exists |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
|
|
@ -139,7 +141,8 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
||||||
{
|
{
|
||||||
plugin_manager->RemovePlugin(to_file);
|
plugin_manager->RemovePlugin(to_file);
|
||||||
|
|
||||||
filesystem::copy(from_path, to_path, filesystem::copy_options::update_existing);
|
LOG_TRACE("[OpenRGBPluginsPage] Copying from %s to %s", from_path.c_str(), to_path.c_str());
|
||||||
|
filesystem::copy(from_path, to_path, filesystem::copy_options::overwrite_existing);
|
||||||
|
|
||||||
plugin_manager->AddPlugin(to_file);
|
plugin_manager->AddPlugin(to_file);
|
||||||
|
|
||||||
|
|
@ -147,7 +150,7 @@ bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
|
||||||
}
|
}
|
||||||
catch(const std::exception& e)
|
catch(const std::exception& e)
|
||||||
{
|
{
|
||||||
LOG_ERROR("[PluginsManager] Failed to install plugin: %s", e.what());
|
LOG_ERROR("[OpenRGBPluginsPage] Failed to install plugin: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -193,7 +196,7 @@ void Ui::OpenRGBPluginsPage::on_RemovePluginButton_clicked()
|
||||||
&&(plugin_settings["plugins"][plugin_idx].contains("description")))
|
&&(plugin_settings["plugins"][plugin_idx].contains("description")))
|
||||||
{
|
{
|
||||||
if((plugin_settings["plugins"][plugin_idx]["name"] == entries[cur_row]->ui->NameValue->text().toStdString())
|
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"][plugin_idx]["description"] == entries[cur_row]->ui->DescriptionValue->text().toStdString()))
|
||||||
{
|
{
|
||||||
plugin_settings["plugins"].erase(plugin_idx);
|
plugin_settings["plugins"].erase(plugin_idx);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue