]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
[ 1936700 ] wxCAL_SHOW_WEEK_NUMBERS, slightly modified
[wxWidgets.git] / src / common / image.cpp
index e4ccc1b8f322c80e49348c4d96c5e528f48eda24..cf7eb9538bc0486ba271b2ac3ac54776c59fa2d6 100644 (file)
@@ -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;
     }