From 64d498b74edb6d12dddba2ab44ada6435f2442d2 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sun, 29 Dec 2013 23:07:58 +0200 Subject: [PATCH] Plugin manager: Mark plugins that failed to load --- include/platform/wxwidgets/platform.hpp | 1 + src/platform/wxwidgets/editor-plugin.cpp | 29 +++++++++++++++++++++++- src/platform/wxwidgets/main.cpp | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/platform/wxwidgets/platform.hpp b/include/platform/wxwidgets/platform.hpp index 2db190a0..382b2002 100644 --- a/include/platform/wxwidgets/platform.hpp +++ b/include/platform/wxwidgets/platform.hpp @@ -64,6 +64,7 @@ void wxeditor_macro_display(wxWindow* parent); void wxeditor_hexedit_display(wxWindow* parent); void wxeditor_multitrack_display(wxWindow* parent); bool wxeditor_plugin_manager_display(wxWindow* parent); +void wxeditor_plugin_manager_notify_fail(const std::string& libname); //Auxillary windows. void wxwindow_memorysearch_display(); diff --git a/src/platform/wxwidgets/editor-plugin.cpp b/src/platform/wxwidgets/editor-plugin.cpp index 46be8b63..a2f56c76 100644 --- a/src/platform/wxwidgets/editor-plugin.cpp +++ b/src/platform/wxwidgets/editor-plugin.cpp @@ -21,6 +21,16 @@ namespace { + std::set failed_plugins; + + std::string string_add_list(std::string a, std::string b) + { + if(a.length()) + return a + "," + b; + else + return b; + } + std::string get_name(std::string path) { #if defined(_WIN32) || defined(_WIN64) @@ -134,7 +144,11 @@ void wxeditor_plugins::reload_plugins() if(!r) continue; pluginstbl.push_back(std::make_pair(r[1], r[2] == "")); std::string r1 = r[1]; - plugins->Append(towxstring(r1 + ((r[2] == "") ? "" : " (disabled)"))); + std::string attributes; + if(r[2] != "") attributes = string_add_list(attributes, "disabled"); + if(failed_plugins.count(r[1] + "." + extension)) attributes = string_add_list(attributes, "failed"); + if(attributes.length()) attributes = " (" + attributes + ")"; + plugins->Append(towxstring(r1 + attributes)); } bool found = false; @@ -227,6 +241,8 @@ void wxeditor_plugins::on_add(wxCommandEvent& e) if(s.st_mode & 04) s.st_mode |= 01; chmod(nname.c_str(), s.st_mode & 0777); #endif + //The new plugin isn't failed. + failed_plugins.erase(get_name(nname)); std::string disname = nname + ".disabled"; remove(disname.c_str()); reload_plugins(); @@ -251,6 +267,11 @@ void wxeditor_plugins::on_rename(wxCommandEvent& e) if(oname != nname) zip::rename_overwrite(oname.c_str(), nname.c_str()); pluginstbl[sel].first = name2; + if(failed_plugins.count(name + "." + extension)) { + failed_plugins.insert(name2 + "." + extension); + failed_plugins.erase(name + "." + extension); + } else + failed_plugins.erase(name2 + "." + extension); reload_plugins(); } @@ -290,6 +311,7 @@ void wxeditor_plugins::on_delete(wxCommandEvent& e) reload_plugins(); return; } + failed_plugins.erase(pluginstbl[sel].first + "." + extension); reload_plugins(); } @@ -324,3 +346,8 @@ bool wxeditor_plugin_manager_display(wxWindow* parent) return false; } } + +void wxeditor_plugin_manager_notify_fail(const std::string& libname) +{ + failed_plugins.insert(libname); +} diff --git a/src/platform/wxwidgets/main.cpp b/src/platform/wxwidgets/main.cpp index 78024037..bb70f65c 100644 --- a/src/platform/wxwidgets/main.cpp +++ b/src/platform/wxwidgets/main.cpp @@ -430,6 +430,7 @@ bool lsnes_app::OnInit() autoload_libraries([](const std::string& libname, const std::string& error) { show_message_ok(NULL, "Error loading plugin " + libname, "Error loading '" + libname + "'\n\n" + error, wxICON_EXCLAMATION); + wxeditor_plugin_manager_notify_fail(libname); }); messages << "Saving per-user data to: " << get_config_path() << std::endl; messages << "--- Loading configuration --- " << std::endl;