diff --git a/src/slic3r/plugin/PluginAuditManager.cpp b/src/slic3r/plugin/PluginAuditManager.cpp index c791b4b02f..f34d9806f6 100644 --- a/src/slic3r/plugin/PluginAuditManager.cpp +++ b/src/slic3r/plugin/PluginAuditManager.cpp @@ -3813,7 +3813,7 @@ bool PluginAuditManager::request_permissions(const std::string& plugin_key, cons // that has not been given one yet and is seeded when the grant is saved. if (state_status == InstallStateReadStatus::Unreadable) return false; - if (!audit_state_belongs_to_loaded_identity(plugin_key, descriptor.plugin_root, state.installation_revision)) { + if (!PluginAuditDetail::audit_state_belongs_to_loaded_identity(plugin_key, descriptor.plugin_root, state.installation_revision)) { BOOST_LOG_TRIVIAL(warning) << "[AUDIT] Refusing to read permissions for a replaced installation: " << plugin_key; return false; } diff --git a/src/slic3r/plugin/PluginBrowserProfile.cpp b/src/slic3r/plugin/PluginBrowserProfile.cpp index f494d8d8d8..8e95d1c250 100644 --- a/src/slic3r/plugin/PluginBrowserProfile.cpp +++ b/src/slic3r/plugin/PluginBrowserProfile.cpp @@ -6,8 +6,8 @@ #include "libslic3r/Utils.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/I18N.hpp" -#include "slic3r/GUI/NotificationManager.hpp" -#include "slic3r/GUI/Plater.hpp" +#include "slic3r/GUI/MsgDialog.hpp" +#include "slic3r/GUI/PluginsDialog.hpp" #include "slic3r/GUI/Widgets/WebView.hpp" #include "slic3r/GUI/format.hpp" @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include namespace Slic3r { @@ -47,6 +49,24 @@ namespace { namespace fs = boost::filesystem; +// boost::filesystem::exists() may surface a missing path as an error on some Windows +// configurations. Treat only genuine file/path-not-found as absence; every other error is a +// real failure and must still be reported. +bool is_path_not_found(const boost::system::error_code& ec) +{ + if (!ec) + return false; + if (ec == boost::system::errc::no_such_file_or_directory) + return true; +#ifdef _WIN32 + if (ec.category() == boost::system::system_category()) { + const DWORD code = static_cast(ec.value()); + return code == ERROR_FILE_NOT_FOUND || code == ERROR_PATH_NOT_FOUND; + } +#endif + return false; +} + fs::path profiles_root() { return fs::path(Slic3r::data_dir()) / "web_profiles"; @@ -165,16 +185,44 @@ std::unordered_map& identities() return *map; } -void push_warning_notification(const std::string& message) +void show_profile_warning(const std::string& message) { - if (GUI::Plater* plater = GUI::wxGetApp().plater()) - plater->get_notification_manager()->push_notification( - GUI::NotificationType::CustomNotification, - GUI::NotificationManager::NotificationLevel::WarningNotificationLevel, message); + // ShowModal runs a nested event loop. Queue subsequent warnings rather than stacking dialogs. + static std::deque pending; + static bool showing = false; + pending.push_back(message); + if (showing) + return; + showing = true; + while (!pending.empty() && wxTheApp != nullptr && !GUI::wxGetApp().is_closing()) { + std::string current = std::move(pending.front()); + pending.pop_front(); + + wxWindow* parent = wxGetActiveWindow(); + if (parent == nullptr || !parent->IsShownOnScreen() || parent->IsBeingDeleted() || + parent == GUI::wxGetApp().GetTopWindow()) { + parent = nullptr; + for (wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext()) { + wxWindow* window = node->GetData(); + if (dynamic_cast(window) && window->IsShownOnScreen() && !window->IsBeingDeleted()) { + parent = window; + break; + } + } + if (parent == nullptr) + parent = GUI::wxGetApp().GetTopWindow(); + } + if (parent && !parent->IsBeingDeleted()) { + GUI::WarningDialog dialog(parent, wxString::FromUTF8(current)); + dialog.ShowModal(); + } + } + pending.clear(); + showing = false; } // Startup/reset warnings can be produced before the plater exists. Retry briefly instead of -// dropping the only notification the user would see. +// dropping the only warning the user would see. class WarningRetryTimer : public wxTimer { public: @@ -185,7 +233,7 @@ public: if (wxTheApp == nullptr || GUI::wxGetApp().is_closing()) return; // process is going away; leave the timer to the app teardown if (GUI::wxGetApp().plater() != nullptr) { - push_warning_notification(m_message); + show_profile_warning(m_message); GUI::wxGetApp().CallAfter([this]() { delete this; }); } else if (--m_attempts > 0) { StartOnce(500); @@ -215,7 +263,7 @@ void warn_profile(const std::string& plugin_key, const std::string& message) if (wxTheApp == nullptr || GUI::wxGetApp().is_closing()) return; if (GUI::wxGetApp().plater() != nullptr) { - push_warning_notification(message); + show_profile_warning(message); return; } auto* timer = new WarningRetryTimer(message, 10); @@ -268,7 +316,7 @@ void delete_profile_on_ui_thread(const std::string& plugin_key, const std::strin boost::system::error_code exists_ec; const fs::path root(installation_root); const bool root_exists = fs::exists(root, exists_ec); - if (exists_ec) { + if (exists_ec && !is_path_not_found(exists_ec)) { warn_profile(plugin_key, GUI::format(_u8L("The plugin was removed, but its browser profile could not be checked: %1%"), exists_ec.message())); @@ -329,7 +377,7 @@ void delete_profile_on_ui_thread(const std::string& plugin_key, const std::strin const fs::path live = profiles_root() / profile_id; const bool live_exists = fs::exists(live, ec); - if (ec) { + if (ec && !is_path_not_found(ec)) { warn_profile(plugin_key, GUI::format(_u8L("The plugin was removed, but its browser profile could not be checked: %1%"), ec.message())); @@ -456,7 +504,7 @@ std::string ensure_plugin_browser_profile(const std::string& plugin_key, bool* f const fs::path old = profiles_root() / legacy; boost::system::error_code ec; const bool exists = fs::exists(old, ec); - if (ec) { + if (ec && !is_path_not_found(ec)) { warn_profile(plugin_key, GUI::format(_u8L("A previous browser profile at %1% could not be checked: %2%"), old.string(), ec.message())); @@ -639,7 +687,7 @@ void warn_legacy_plugin_browser_profile(const std::string& plugin_key, const std const fs::path old = profiles_root() / legacy; boost::system::error_code ec; const bool exists = fs::exists(old, ec); - if (ec) { + if (ec && !is_path_not_found(ec)) { warn_profile(plugin_key, GUI::format(_u8L("A previous browser profile at %1% could not be checked: %2%"), old.string(), ec.message())); diff --git a/src/slic3r/plugin/PluginFsUtils.cpp b/src/slic3r/plugin/PluginFsUtils.cpp index 15835d7552..9345e2464d 100644 --- a/src/slic3r/plugin/PluginFsUtils.cpp +++ b/src/slic3r/plugin/PluginFsUtils.cpp @@ -211,6 +211,8 @@ thread_local unsigned t_install_state_depth = 0; class PackageLeaseLock { public: + PackageLeaseLock() = default; + bool open(const std::string& path, std::string& error) { #if defined(_WIN32) diff --git a/src/slic3r/plugin/PluginManager.cpp b/src/slic3r/plugin/PluginManager.cpp index 82d0f69685..58ccf0fe09 100644 --- a/src/slic3r/plugin/PluginManager.cpp +++ b/src/slic3r/plugin/PluginManager.cpp @@ -2662,11 +2662,11 @@ bool PluginManager::update_cloud_plugin(const std::string& plugin_key, std::stri preserved_state.capabilities = previous_state.capabilities; } - const bool installed = install_cloud_plugin_package(plugin_key, version, download.package_path, previous, - &update_cloud_user, install_error, &failure, - had_local_package ? &preserved_state : nullptr, - update_package_lease); - if (!installed) { + const bool installed_ok = install_cloud_plugin_package(plugin_key, version, download.package_path, previous, + &update_cloud_user, install_error, &failure, + had_local_package ? &preserved_state : nullptr, + update_package_lease); + if (!installed_ok) { // Install/revoke are done; release before restoring/reloading the old package. update_package_lease.reset(); // Restoring the old state and reloading the old package is only meaningful when the