From 8fb1152eeea6f48c4ac8a748be326872b0fe42d3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 13 Nov 2018 16:11:24 +0100 Subject: [PATCH] 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. --- samples/drawing/drawing.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index b9da4ce65a..fd7e032661 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -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; }