From a57a9dc700d66614f57d18b321d8db0db93033ca Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Thu, 10 May 2018 19:08:58 -0500 Subject: [PATCH] Set the bitmap type (needed for wxMSW) and check that the load happens before trying to use it. --- src/GUI/MainFrame.cpp | 7 +------ src/GUI/misc_ui.hpp | 9 +++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index 7a99f5f25..2ee7bba9e 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -17,12 +17,7 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si : wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false), tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(_gui_config), preset_editor_tabs(std::map()) { - // Set icon to either the .ico if windows or png for everything else. - if (the_os == OS::Windows) - this->SetIcon(wxIcon(var("Slic3r.ico"), wxBITMAP_TYPE_ICO)); - else - this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG)); - + this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG)); this->init_tabpanel(); this->init_menubar(); diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index b22c73b3a..51a677504 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -115,8 +115,13 @@ void append_menu_item(wxMenu* menu, const wxString& name,const wxString& help, T tmp->SetAccel(a); // set the accelerator if and only if the accelerator is fine } tmp->SetHelp(help); - if (!icon.IsEmpty()) - tmp->SetBitmap(wxBitmap(var(icon))); + if (!icon.IsEmpty()) { + wxBitmap ico; + if(ico.LoadFile(var(icon), wxBITMAP_TYPE_PNG)) + tmp->SetBitmap(ico); + else + std::cerr<< var(icon) << " failed to load \n"; + } if (typeid(lambda) != typeid(nullptr)) menu->Bind(wxEVT_MENU, lambda, tmp->GetId(), tmp->GetId());