From 247d46319e545a12f76e08776f97dd628847b41d Mon Sep 17 00:00:00 2001 From: Bill Gianopoulos Date: Thu, 24 Mar 2022 10:38:59 +0000 Subject: [PATCH] Bug 1762731 - Use more automatic memory management in GTK code. r=frg Port Bug 1760839 "Use more automatic memory management in GTK code". --- suite/components/shell/nsGNOMEShellService.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/suite/components/shell/nsGNOMEShellService.cpp b/suite/components/shell/nsGNOMEShellService.cpp index 4eb826babd..15ea0e1131 100644 --- a/suite/components/shell/nsGNOMEShellService.cpp +++ b/suite/components/shell/nsGNOMEShellService.cpp @@ -24,6 +24,7 @@ #include "nsIImageLoadingContent.h" #include "imgIRequest.h" #include "imgIContainer.h" +#include "mozilla/GRefPtr.h" #include "mozilla/Sprintf.h" #include "mozilla/dom/Element.h" #if defined(MOZ_WIDGET_GTK) @@ -287,14 +288,12 @@ static nsresult WriteImage(const nsCString &aPath, imgIContainer *aImage) { #if !defined(MOZ_WIDGET_GTK) return NS_ERROR_NOT_AVAILABLE; #else - GdkPixbuf* pixbuf = nsImageToPixbuf::ImageToPixbuf(aImage); + RefPtr pixbuf = nsImageToPixbuf::ImageToPixbuf(aImage); if (!pixbuf) { return NS_ERROR_NOT_AVAILABLE; } gboolean res = gdk_pixbuf_save(pixbuf, aPath.get(), "png", nullptr, nullptr); - - g_object_unref(pixbuf); return res ? NS_OK : NS_ERROR_FAILURE; #endif }