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.
This commit is contained in:
YuSanka 2024-03-06 12:19:10 +01:00
parent c857ae8db5
commit 8c2f6d7b7d
5 changed files with 19 additions and 9 deletions

View File

@ -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)

View File

@ -12,7 +12,7 @@
#include "ConfigWizard.hpp"
#include "OpenGLManager.hpp"
#include "libslic3r/Preset.hpp"
#include "Search.hpp"
#include "I18N.hpp"
#include <wx/app.h>
#include <wx/colour.h>
@ -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);

View File

@ -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())

View File

@ -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;

View File

@ -20,6 +20,7 @@
#include "OG_CustomCtrl.hpp"
#include "GLCanvas3D.hpp"
#include "ConfigWizard.hpp"
#include "Search.hpp"
#include "Widgets/SpinInput.hpp"