]> git.saurik.com Git - wxWidgets.git/commitdiff
Do a sanity check before reading. Otherwise, if trying to read a duff image file,
authorJulian Smart <julian@anthemion.co.uk>
Wed, 26 Oct 2005 14:08:43 +0000 (14:08 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 26 Oct 2005 14:08:43 +0000 (14:08 +0000)
the app can abort if you pass a specific image type, but simply show an error
message if you pass wxBITMAP_TYPE_ANY.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36019 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/image.cpp

index c888353fd9b801ee1bd972f4bc67ed7d23c02d78..e967b8ece9fd4c49ca690ad391b59302102056c5 100644 (file)
@@ -1554,7 +1554,13 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index )
         return false;
     }
 
-    return handler->LoadFile(this, stream, true/*verbose*/, index);
+    if (!handler->CanRead(stream))
+    {
+        wxLogError(_("Image file is not of type %d."), type);
+        return false;
+    }
+    else
+        return handler->LoadFile(this, stream, true/*verbose*/, index);
 }
 
 bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int index )
@@ -1572,7 +1578,13 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int ind
         return false;
     }
 
-    return handler->LoadFile( this, stream, true/*verbose*/, index );
+    if (!handler->CanRead(stream))
+    {
+        wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype);
+        return false;
+    }
+    else
+        return handler->LoadFile( this, stream, true/*verbose*/, index );
 }
 
 bool wxImage::SaveFile( wxOutputStream& stream, int type ) const