]> git.saurik.com Git - wxWidgets.git/commitdiff
don't try to save invalid image: added a wxCHECK(Ok()) to Save() overloads which...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 1 Mar 2005 17:42:28 +0000 (17:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 1 Mar 2005 17:42:28 +0000 (17:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/image.cpp

index 2a8b2013ff0076ebd8afff5877a124c9dec08f2a..627bcadcf2bfa83415e41e4421cede5e506562ab 100644 (file)
@@ -1262,6 +1262,8 @@ bool wxImage::SaveFile( const wxString& filename ) const
 bool wxImage::SaveFile( const wxString& filename, int type ) const
 {
 #if wxUSE_STREAMS
+    wxCHECK_MSG( Ok(), false, wxT("invalid image") );
+
     ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
 
     wxFileOutputStream stream(filename);
@@ -1279,6 +1281,8 @@ bool wxImage::SaveFile( const wxString& filename, int type ) const
 bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) const
 {
 #if wxUSE_STREAMS
+    wxCHECK_MSG( Ok(), false, wxT("invalid image") );
+
     ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
 
     wxFileOutputStream stream(filename);
@@ -1428,8 +1432,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) const
     wxCHECK_MSG( Ok(), false, wxT("invalid image") );
 
     wxImageHandler *handler = FindHandler(type);
-
-    if (handler == 0)
+    if ( !handler )
     {
         wxLogWarning( _("No image handler for type %d defined."), type );
 
@@ -1444,8 +1447,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype ) const
     wxCHECK_MSG( Ok(), false, wxT("invalid image") );
 
     wxImageHandler *handler = FindHandlerMime(mimetype);
-
-    if (handler == 0)
+    if ( !handler )
     {
         wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );