From 339e5c10133c4e7302b0afef12d0ff48236e7acd Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 4 Jun 2018 16:19:17 -0500 Subject: [PATCH] Changed small_font to be a function; avoids initialization segfault (calling wxSystemSettings before wx is initialized). --- src/GUI/Plater.cpp | 10 +++++----- src/GUI/Plater.hpp | 4 ++-- src/GUI/misc_ui.cpp | 2 ++ src/GUI/misc_ui.hpp | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index 40d80fa99..83d937d41 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -154,7 +154,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptrAdd(sizer, 0, wxEXPAND | wxBOTTOM, 5); 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); /* 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_ptrobject_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); // Select object on change. @@ -183,11 +183,11 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptrSetFont(small_font); + text->SetFont(small_font()); grid_sizer->Add(text, 0); 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->Hide(); @@ -1088,7 +1088,7 @@ void Plater::build_preset_chooser() { break; } 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)}; this->preset_choosers[static_cast(group)] = choice; diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index 5c14f5f3a..7dd226d89 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -266,11 +266,11 @@ template static void add_info_field(wxWindow* parent, T*& field, wxString name, wxGridSizer* sizer) { name << ":"; auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; - text->SetFont(small_font); + text->SetFont(small_font()); sizer->Add(text, 0); field = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - field->SetFont(small_font); + field->SetFont(small_font()); sizer->Add(field, 0); } diff --git a/src/GUI/misc_ui.cpp b/src/GUI/misc_ui.cpp index 41c1f17f0..95febae57 100644 --- a/src/GUI/misc_ui.cpp +++ b/src/GUI/misc_ui.cpp @@ -147,5 +147,7 @@ std::vector open_model(wxWindow* parent, const Settings& settings, wxW return tmp; } +wxFont small_font() { return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); } + }} // namespace Slic3r::GUI diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index 40b3b4b81..cbf1e5134 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -51,8 +51,8 @@ constexpr bool isDev = 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 const std::map FILE_WILDCARDS {