From: Vadim Zeitlin Date: Sun, 6 Apr 2008 15:31:18 +0000 (+0000) Subject: continue with other handlers if some handler fails in LoadFile() after returning... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f71b0c2d56b03b7823e661aacd05cf1a791e5c2f?ds=sidebyside continue with other handlers if some handler fails in LoadFile() after returning true from CanRead() (modified patch 1926226) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53048 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/image.cpp b/src/common/image.cpp index e4ccc1b8f3..3f25322183 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -2159,13 +2159,19 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) if ( type == wxBITMAP_TYPE_ANY ) { - wxList &list=GetHandlers(); + const wxList& list = GetHandlers(); - for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) + for ( wxList::compatibility_iterator node = list.GetFirst(); + node; + node = node->GetNext() ) { - handler=(wxImageHandler*)node->GetData(); + handler = (wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) - return handler->GetImageCount(stream); + { + const int count = handler->GetImageCount(stream); + if ( count >= 0 ) + return count; + } } @@ -2202,17 +2208,22 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) if ( type == wxBITMAP_TYPE_ANY ) { - wxList &list=GetHandlers(); - - for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) + const wxList& list = GetHandlers(); + for ( wxList::compatibility_iterator node = list.GetFirst(); + node; + node = node->GetNext() ) { - handler=(wxImageHandler*)node->GetData(); - if ( handler->CanRead(stream) ) - return handler->LoadFile(this, stream, true/*verbose*/, index); + handler = (wxImageHandler*)node->GetData(); + if ( handler->CanRead(stream) && + handler->LoadFile(this, stream, true/*verbose*/, index) ) + { + return true; + } } wxLogWarning( _("No handler found for image type.") ); + return false; }