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:
Vadim Zeitlin
2018-11-13 16:11:24 +01:00
parent 8793e7fc11
commit 8fb1152eee

View File

@@ -461,6 +461,10 @@ bool MyApp::OnInit()
if ( !wxApp::OnInit() ) if ( !wxApp::OnInit() )
return false; return false;
#if wxUSE_LIBPNG
wxImage::AddHandler( new wxPNGHandler );
#endif
// Create the main application window // Create the main application window
MyFrame *frame = new MyFrame("Drawing sample", MyFrame *frame = new MyFrame("Drawing sample",
wxDefaultPosition, wxSize(550, 840)); wxDefaultPosition, wxSize(550, 840));
@@ -477,9 +481,6 @@ bool MyApp::OnInit()
// still continue, the sample can be used without images too if they're // still continue, the sample can be used without images too if they're
// missing for whatever reason // missing for whatever reason
} }
#if wxUSE_LIBPNG
wxImage::AddHandler( new wxPNGHandler );
#endif
return true; return true;
} }