Set the bitmap type (needed for wxMSW) and check that the load happens before trying to use it.

This commit is contained in:
Joseph Lenox 2018-05-10 19:08:58 -05:00
parent aba90c705a
commit a57a9dc700
2 changed files with 8 additions and 8 deletions

View File

@ -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<wxWindowID, PresetEditor*>())
{
// 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();

View File

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