Fix of GCodeViewer crashes when opening app preferences #7430
This commit is contained in:
parent
bfce4f6901
commit
d4d558ebee
@ -9,7 +9,6 @@
|
|||||||
#include "Notebook.hpp"
|
#include "Notebook.hpp"
|
||||||
#include "ButtonsDescription.hpp"
|
#include "ButtonsDescription.hpp"
|
||||||
#include "OG_CustomCtrl.hpp"
|
#include "OG_CustomCtrl.hpp"
|
||||||
#include <initializer_list>
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
@ -519,21 +518,29 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||||||
this->CenterOnParent();
|
this->CenterOnParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::update_ctrls_alignment()
|
std::vector<ConfigOptionsGroup*> PreferencesDialog::optgroups()
|
||||||
{
|
{
|
||||||
int max_ctrl_width{ 0 };
|
std::vector<ConfigOptionsGroup*> out;
|
||||||
std::initializer_list<ConfigOptionsGroup*> og_list = { m_optgroup_general.get(), m_optgroup_camera.get(), m_optgroup_gui.get()
|
out.reserve(4);
|
||||||
|
for (ConfigOptionsGroup* opt : { m_optgroup_general.get(), m_optgroup_camera.get(), m_optgroup_gui.get()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
, m_optgroup_dark_mode.get()
|
, m_optgroup_dark_mode.get()
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
};
|
})
|
||||||
for (auto og : og_list) {
|
if (opt)
|
||||||
|
out.emplace_back(opt);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::update_ctrls_alignment()
|
||||||
|
{
|
||||||
|
int max_ctrl_width{ 0 };
|
||||||
|
for (ConfigOptionsGroup* og : this->optgroups())
|
||||||
if (int max = og->custom_ctrl->get_max_win_width();
|
if (int max = og->custom_ctrl->get_max_win_width();
|
||||||
max_ctrl_width < max)
|
max_ctrl_width < max)
|
||||||
max_ctrl_width = max;
|
max_ctrl_width = max;
|
||||||
}
|
|
||||||
if (max_ctrl_width)
|
if (max_ctrl_width)
|
||||||
for (auto og : og_list)
|
for (ConfigOptionsGroup* og : this->optgroups())
|
||||||
og->custom_ctrl->set_max_win_width(max_ctrl_width);
|
og->custom_ctrl->set_max_win_width(max_ctrl_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,9 +629,8 @@ void PreferencesDialog::accept(wxEvent&)
|
|||||||
|
|
||||||
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
|
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
{
|
{
|
||||||
m_optgroup_general->msw_rescale();
|
for (ConfigOptionsGroup* og : this->optgroups())
|
||||||
m_optgroup_camera->msw_rescale();
|
og->msw_rescale();
|
||||||
m_optgroup_gui->msw_rescale();
|
|
||||||
|
|
||||||
msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL });
|
msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL });
|
||||||
|
|
||||||
@ -788,7 +794,7 @@ void PreferencesDialog::init_highlighter(const t_config_option_key& opt_key)
|
|||||||
});
|
});
|
||||||
|
|
||||||
std::pair<OG_CustomCtrl*, bool*> ctrl = { nullptr, nullptr };
|
std::pair<OG_CustomCtrl*, bool*> ctrl = { nullptr, nullptr };
|
||||||
for (auto opt_group : { m_optgroup_general, m_optgroup_camera, m_optgroup_gui }) {
|
for (ConfigOptionsGroup* opt_group : this->optgroups()) {
|
||||||
ctrl = opt_group->get_custom_ctrl_with_blinking_ptr(opt_key, -1);
|
ctrl = opt_group->get_custom_ctrl_with_blinking_ptr(opt_key, -1);
|
||||||
if (ctrl.first && ctrl.second) {
|
if (ctrl.first && ctrl.second) {
|
||||||
m_highlighter.init(ctrl);
|
m_highlighter.init(ctrl);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class wxColourPickerCtrl;
|
class wxColourPickerCtrl;
|
||||||
@ -61,6 +62,7 @@ protected:
|
|||||||
void create_settings_mode_widget();
|
void create_settings_mode_widget();
|
||||||
void create_settings_text_color_widget();
|
void create_settings_text_color_widget();
|
||||||
void init_highlighter(const t_config_option_key& opt_key);
|
void init_highlighter(const t_config_option_key& opt_key);
|
||||||
|
std::vector<ConfigOptionsGroup*> optgroups();
|
||||||
|
|
||||||
struct PreferencesHighlighter
|
struct PreferencesHighlighter
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user