Fix leak of GdkPixbufLoader in wxGTK wxAnimation
Use wxGtkObject<> to ensure that the loader object is unref'd. Also add a missing call to gdk_pixbuf_loader_close() for consistency. Closes #17607.
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
|
#include "wx/gtk/private/object.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@@ -116,6 +117,8 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type)
|
|||||||
else
|
else
|
||||||
loader = gdk_pixbuf_loader_new();
|
loader = gdk_pixbuf_loader_new();
|
||||||
|
|
||||||
|
wxGtkObject<GdkPixbufLoader> ensureUnrefLoader(loader);
|
||||||
|
|
||||||
if (!loader ||
|
if (!loader ||
|
||||||
error != NULL) // even if the loader was allocated, an error could have happened
|
error != NULL) // even if the loader was allocated, an error could have happened
|
||||||
{
|
{
|
||||||
@@ -156,6 +159,7 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type)
|
|||||||
if (!data_written)
|
if (!data_written)
|
||||||
{
|
{
|
||||||
wxLogDebug("Could not read data from the stream...");
|
wxLogDebug("Could not read data from the stream...");
|
||||||
|
gdk_pixbuf_loader_close(loader, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user