X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14678d6d227b7b82ee3250e32109d8fb73372246..7bf2b0881a6bf28138f258504e88b2643daa854e:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index e4ccc1b8f3..cf7eb9538b 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -2066,8 +2066,7 @@ bool wxImage::SaveFile( const wxString& filename ) const wxImageHandler * pHandler = FindHandler(ext, -1); if (pHandler) { - SaveFile(filename, pHandler->GetType()); - return true; + return SaveFile(filename, pHandler->GetType()); } wxLogError(_("Can't save image to file '%s': unknown extension."), filename.c_str()); @@ -2159,13 +2158,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 +2207,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; }