Changed small_font to be a function; avoids initialization segfault (calling wxSystemSettings before wx is initialized).

This commit is contained in:
Joseph Lenox 2018-06-04 16:19:17 -05:00 committed by Joseph Lenox
parent 4781a5ac4b
commit 339e5c1013
4 changed files with 11 additions and 9 deletions

View File

@ -154,7 +154,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
auto* sizer {new wxBoxSizer(wxHORIZONTAL)}; auto* sizer {new wxBoxSizer(wxHORIZONTAL)};
object_info_sizer->Add(sizer, 0, wxEXPAND | wxBOTTOM, 5); object_info_sizer->Add(sizer, 0, wxEXPAND | wxBOTTOM, 5);
auto* text {new wxStaticText(this, wxID_ANY, _("Object:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; auto* text {new wxStaticText(this, wxID_ANY, _("Object:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
text->SetFont(small_font); text->SetFont(small_font());
sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL); sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL);
/* We supply a bogus width to wxChoice (sizer will override it and stretch /* We supply a bogus width to wxChoice (sizer will override it and stretch
@ -162,7 +162,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
* too much according to the contents, and this is bad with long file names. * too much according to the contents, and this is bad with long file names.
*/ */
this->object_info.choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100, -1)); this->object_info.choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100, -1));
this->object_info.choice->SetFont(small_font); this->object_info.choice->SetFont(small_font());
sizer->Add(this->object_info.choice, 1, wxALIGN_CENTER_VERTICAL); sizer->Add(this->object_info.choice, 1, wxALIGN_CENTER_VERTICAL);
// Select object on change. // Select object on change.
@ -183,11 +183,11 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
{ {
wxString name {"Manifold:"}; wxString name {"Manifold:"};
auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
text->SetFont(small_font); text->SetFont(small_font());
grid_sizer->Add(text, 0); grid_sizer->Add(text, 0);
this->object_info.manifold = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); this->object_info.manifold = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
this->object_info.manifold->SetFont(small_font); this->object_info.manifold->SetFont(small_font());
this->object_info.manifold_warning_icon = new wxStaticBitmap(this, wxID_ANY, wxBitmap(var("error.png"), wxBITMAP_TYPE_PNG)); this->object_info.manifold_warning_icon = new wxStaticBitmap(this, wxID_ANY, wxBitmap(var("error.png"), wxBITMAP_TYPE_PNG));
this->object_info.manifold_warning_icon->Hide(); this->object_info.manifold_warning_icon->Hide();
@ -1088,7 +1088,7 @@ void Plater::build_preset_chooser() {
break; break;
} }
auto* text {new wxStaticText(this, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT)}; auto* text {new wxStaticText(this, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT)};
text->SetFont(small_font); text->SetFont(small_font());
auto* choice {new wxBitmapComboBox(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY)}; auto* choice {new wxBitmapComboBox(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY)};
this->preset_choosers[static_cast<int>(group)] = choice; this->preset_choosers[static_cast<int>(group)] = choice;

View File

@ -266,11 +266,11 @@ template <typename T>
static void add_info_field(wxWindow* parent, T*& field, wxString name, wxGridSizer* sizer) { static void add_info_field(wxWindow* parent, T*& field, wxString name, wxGridSizer* sizer) {
name << ":"; name << ":";
auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
text->SetFont(small_font); text->SetFont(small_font());
sizer->Add(text, 0); sizer->Add(text, 0);
field = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); field = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
field->SetFont(small_font); field->SetFont(small_font());
sizer->Add(field, 0); sizer->Add(field, 0);
} }

View File

@ -147,5 +147,7 @@ std::vector<wxString> open_model(wxWindow* parent, const Settings& settings, wxW
return tmp; return tmp;
} }
wxFont small_font() { return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); }
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI

View File

@ -51,8 +51,8 @@ constexpr bool isDev = false;
constexpr bool threaded = false; constexpr bool threaded = false;
const wxFont small_font { wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; /// Font definition
wxFont small_font();
// hopefully the compiler is smart enough to figure this out // hopefully the compiler is smart enough to figure this out
const std::map<const std::string, const std::string> FILE_WILDCARDS { const std::map<const std::string, const std::string> FILE_WILDCARDS {