Bug 616994. Don't leak the buffer we create for the drag image. r=roc, a=blocker

This commit is contained in:
Boris Zbarsky 2010-12-07 08:54:50 -05:00
parent 9d901fdd66
commit 5f268dee3c
3 changed files with 12 additions and 2 deletions

View File

@ -257,10 +257,12 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
if (!SetAlphaPixmap(surface, context, offsetX, offsetY, dragRect)) {
GdkPixbuf* dragPixbuf =
nsImageToPixbuf::SurfaceToPixbuf(surface, dragRect.width, dragRect.height);
if (dragPixbuf)
if (dragPixbuf) {
gtk_drag_set_icon_pixbuf(context, dragPixbuf, offsetX, offsetY);
else
g_object_unref(dragPixbuf);
} else {
needsFallbackIcon = PR_TRUE;
}
}
} else {
needsFallbackIcon = PR_TRUE;

View File

@ -54,6 +54,10 @@ class nsIImageToPixbuf : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NSIIMAGETOPIXBUF_IID)
/**
* The return value, if not null, should be released as needed
* by the caller using g_object_unref.
*/
NS_IMETHOD_(GdkPixbuf*) ConvertImageToPixbuf(imgIContainer* aImage) = 0;
};

View File

@ -51,6 +51,10 @@ class nsImageToPixbuf : public nsIImageToPixbuf {
// Friendlier version of ConvertImageToPixbuf for callers inside of
// widget
/**
* The return value of all these, if not null, should be
* released as needed by the caller using g_object_unref.
*/
static GdkPixbuf* ImageToPixbuf(imgIContainer * aImage);
static GdkPixbuf* SurfaceToPixbuf(gfxASurface* aSurface,
PRInt32 aWidth, PRInt32 aHeight);