wxFileOutputStream stream(filename);
- if ( stream.LastError() == wxStream_NOERROR )
+ if ( stream.IsOk() )
{
wxBufferedOutputStream bstream( stream );
return SaveFile(bstream, type);
wxFileOutputStream stream(filename);
- if ( stream.LastError() == wxStream_NOERROR )
+ if ( stream.IsOk() )
{
wxBufferedOutputStream bstream( stream );
return SaveFile(bstream, mimetype);
{
#if wxUSE_STREAMS
wxFileInputStream stream(name);
- return GetImageCount(stream, type);
-#else
- return 0;
+ if (stream.Ok())
+ return GetImageCount(stream, type);
#endif
+
+ return 0;
}
#if wxUSE_STREAMS
handler = FindHandler(type);
- if (handler == NULL)
+ if (handler == 0)
{
wxLogWarning( _("No image handler for type %d defined."), type );
wxImageHandler *handler = FindHandlerMime(mimetype);
- if (handler == NULL)
+ if (handler == 0)
{
wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );
wxImageHandler *handler = FindHandler(type);
- if (handler == NULL)
+ if (handler == 0)
{
wxLogWarning( _("No image handler for type %d defined."), type );
wxImageHandler *handler = FindHandlerMime(mimetype);
- if (handler == NULL)
+ if (handler == 0)
{
wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );
// make sure that the memory will be freed at the program end
sm_handlers.DeleteContents(TRUE);
- sm_handlers.Append( handler );
+ // Check for an existing handler of the type being added.
+ if (FindHandler( handler->GetType() ) == 0)
+ {
+ sm_handlers.Append( handler );
+ }
+ else
+ {
+ // This is not documented behaviour, merely the simplest 'fix'
+ // for preventing duplicate additions. If someone ever has
+ // a good reason to add and remove duplicate handlers (and they
+ // may) we should probably refcount the duplicates.
+ // also an issue in InsertHandler below.
+
+ wxLogDebug( _T("Adding duplicate image handler for '%s'"),
+ handler->GetName().c_str() );
+ delete handler;
+ }
}
void wxImage::InsertHandler( wxImageHandler *handler )
// make sure that the memory will be freed at the program end
sm_handlers.DeleteContents(TRUE);
- sm_handlers.Insert( handler );
+ // Check for an existing handler of the type being added.
+ if (FindHandler( handler->GetType() ) == 0)
+ {
+ sm_handlers.Insert( handler );
+ }
+ else
+ {
+ // see AddHandler for additional comments.
+ wxLogDebug( _T("Inserting duplicate image handler for '%s'"),
+ handler->GetName().c_str() );
+ delete handler;
+ }
}
bool wxImage::RemoveHandler( const wxString& name )
node = node->Next();
}
- return (wxImageHandler *)NULL;
+ return 0;
}
wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType )
return handler;
node = node->Next();
}
- return (wxImageHandler*)NULL;
+ return 0;
}
wxImageHandler *wxImage::FindHandler( long bitmapType )
if (handler->GetType() == bitmapType) return handler;
node = node->Next();
}
- return NULL;
+ return 0;
}
wxImageHandler *wxImage::FindHandlerMime( const wxString& mimetype )
if (handler->GetMimeType().IsSameAs(mimetype, FALSE)) return handler;
node = node->Next();
}
- return NULL;
+ return 0;
}
void wxImage::InitStandardHandlers()
#if wxUSE_STREAMS
AddHandler(new wxBMPHandler);
#endif // wxUSE_STREAMS
-
-#if wxUSE_XPM && !defined(__WXGTK__) && !defined(__WXMOTIF__)
- AddHandler(new wxXPMHandler);
-#endif
}
void wxImage::CleanUpHandlers()
//-----------------------------------------------------------------------------
-// Deprecated wxBitmap convertion routines
+// Deprecated wxBitmap conversion routines
//-----------------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_2_2 && wxUSE_GUI