From 8c2f6d7b7dc00568f5ebc571df406c9ffacc619c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 6 Mar 2024 12:19:10 +0100 Subject: [PATCH] Fixed an update of Searcher on UI recreation. Bug was caused by fa86a3d0, when instance of searcher was moved to GuiApp and as result wasn't recreate on UI recreation. Searcher instance is in MainFrame now. --- src/slic3r/GUI/GUI_App.cpp | 12 ++++++------ src/slic3r/GUI/GUI_App.hpp | 11 ++++++++--- src/slic3r/GUI/MainFrame.cpp | 2 ++ src/slic3r/GUI/MainFrame.hpp | 2 ++ src/slic3r/GUI/Preferences.cpp | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 46bc5011a8..ebd79f8892 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1099,7 +1099,7 @@ void GUI_App::check_and_update_searcher(ConfigOptionMode mode /*= comExpert*/) if (tab->supports_printer_technology(print_tech)) search_inputs.emplace_back(Search::InputInfo{ tab->get_config(), tab->type() }); - m_searcher.check_and_update(print_tech, mode, search_inputs); + m_searcher->check_and_update(print_tech, mode, search_inputs); } void GUI_App::jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category) @@ -1109,7 +1109,7 @@ void GUI_App::jump_to_option(const std::string& opt_key, Preset::Type type, cons void GUI_App::jump_to_option(size_t selected) { - const Search::Option& opt = m_searcher.get_option(selected); + const Search::Option& opt = m_searcher->get_option(selected); if (opt.type == Preset::TYPE_PREFERENCES) open_preferences(opt.opt_key(), into_u8(opt.group)); else @@ -1128,12 +1128,12 @@ void GUI_App::jump_to_option(const std::string& composite_key) // Regularly searcher is sorted in respect to the options labels, // so resort searcher before get an option - m_searcher.sort_options_by_key(); - const Search::Option& opt = m_searcher.get_option(opt_key, tab->type()); + m_searcher->sort_options_by_key(); + const Search::Option& opt = m_searcher->get_option(opt_key, tab->type()); tab->activate_option(opt_key, into_u8(opt.category)); // Revert sort of searcher back - m_searcher.sort_options_by_label(); + m_searcher->sort_options_by_label(); break; } } @@ -1142,7 +1142,7 @@ void GUI_App::jump_to_option(const std::string& composite_key) void GUI_App::show_search_dialog() { check_and_update_searcher(get_mode()); - m_searcher.show_dialog(); + m_searcher->show_dialog(); } static int get_app_font_pt_size(const AppConfig* app_config) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 75236ba83a..726a1689aa 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -12,7 +12,7 @@ #include "ConfigWizard.hpp" #include "OpenGLManager.hpp" #include "libslic3r/Preset.hpp" -#include "Search.hpp" +#include "I18N.hpp" #include #include @@ -40,6 +40,10 @@ class PrintHostJobQueue; class Model; class AppUpdater; +namespace Search { + class OptionsSearcher; +} + namespace GUI{ class RemovableDriveManager; @@ -176,7 +180,7 @@ private: std::string m_instance_hash_string; size_t m_instance_hash_int; - Search::OptionsSearcher m_searcher; + Search::OptionsSearcher* m_searcher{ nullptr }; public: bool OnInit() override; @@ -191,7 +195,8 @@ public: bool is_recreating_gui() const { return m_is_recreating_gui; } std::string logo_name() const { return is_editor() ? "PrusaSlicer" : "PrusaSlicer-gcodeviewer"; } - Search::OptionsSearcher& searcher() noexcept { return m_searcher; } + Search::OptionsSearcher& searcher() noexcept { return *m_searcher; } + void set_searcher(Search::OptionsSearcher* searcher) { m_searcher = searcher; } void check_and_update_searcher(ConfigOptionMode mode = comExpert); void jump_to_option(size_t selected); void jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index e6cc320a2d..7c28b9eb36 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -166,6 +166,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S // Load the icon either from the exe, or from the ico file. SetIcon(main_frame_icon(wxGetApp().get_app_mode())); + wxGetApp().set_searcher(&m_searcher); + // initialize tabpanel and menubar init_tabpanel(); if (wxGetApp().is_gcode_viewer()) diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 8b49331295..37fcfc3ab2 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -27,6 +27,7 @@ #include "GUI_Utils.hpp" #include "Event.hpp" #include "UnsavedChangesDialog.hpp" +#include "Search.hpp" class wxBookCtrlBase; class wxProgressDialog; @@ -93,6 +94,7 @@ class MainFrame : public DPIFrame wxSizer* m_main_sizer{ nullptr }; size_t m_last_selected_tab; + Search::OptionsSearcher m_searcher; std::string get_base_name(const wxString &full_name, const char *extension = nullptr) const; std::string get_dir_name(const wxString &full_name) const; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 00c96576e9..ee4c06f4a1 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -20,6 +20,7 @@ #include "OG_CustomCtrl.hpp" #include "GLCanvas3D.hpp" #include "ConfigWizard.hpp" +#include "Search.hpp" #include "Widgets/SpinInput.hpp"