Fix error about duplicate PNG image handler in the drawing sample
Add the handler earlier, as creating the handler main frame uses wxArtProvider::GetBitmap() which can add the PNG handler on some platforms (e.g. macOS, when using wxTangoArtProvider), so calling wxImage::AddHandler() again after creating the frame could result in a debug error message about adding the same handler twice.
This commit is contained in:
@@ -461,6 +461,10 @@ bool MyApp::OnInit()
|
||||
if ( !wxApp::OnInit() )
|
||||
return false;
|
||||
|
||||
#if wxUSE_LIBPNG
|
||||
wxImage::AddHandler( new wxPNGHandler );
|
||||
#endif
|
||||
|
||||
// Create the main application window
|
||||
MyFrame *frame = new MyFrame("Drawing sample",
|
||||
wxDefaultPosition, wxSize(550, 840));
|
||||
@@ -477,9 +481,6 @@ bool MyApp::OnInit()
|
||||
// still continue, the sample can be used without images too if they're
|
||||
// missing for whatever reason
|
||||
}
|
||||
#if wxUSE_LIBPNG
|
||||
wxImage::AddHandler( new wxPNGHandler );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user