Skip to content
Snippets Groups Projects
Commit 576d7890 authored by mattm@chromium.org's avatar mattm@chromium.org
Browse files

Linux: Fix some GdkPixbuf leaks.

Also expand some documentation for functions that returned a GdkPixbuf about
who owns the reference

BUG=38895
TEST=manual test that nothing is broken, will watch bot for leak results

Review URL: http://codereview.chromium.org/1075014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42302 0039d316-1c4b-4281-b951-d872f2087c98
parent d73545f4
No related branches found
No related tags found
No related merge requests found
......@@ -130,6 +130,8 @@ class BrowserThemeProvider : public NonThreadSafe,
virtual bool HasCustomImage(int id) const;
virtual RefCountedMemory* GetRawData(int id) const;
#if defined(OS_LINUX)
// GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are
// shared instances owned by the theme provider and should not be freed.
virtual GdkPixbuf* GetPixbufNamed(int id) const;
virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const;
#elif defined(OS_MACOSX)
......
......@@ -77,6 +77,7 @@ void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon,
// Put Icon in the left column.
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(skia_icon);
GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
gtk_box_pack_start(GTK_BOX(icon_hbox), icon, TRUE, TRUE, 0);
// Create a new vbox for the right column.
......
......@@ -150,6 +150,7 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
gtk_box_pack_start(GTK_BOX(bubble_content), icon_column, FALSE, FALSE,
kIconPadding);
GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
gtk_box_pack_start(GTK_BOX(icon_column), image, FALSE, FALSE, 0);
// Center text column.
......
......@@ -157,12 +157,15 @@ void HungRendererDialogGtk::ShowForTabContents(TabContents* hung_contents) {
title = UTF16ToUTF8(TabContents::GetDefaultTitle());
SkBitmap favicon = it->GetFavIcon();
GdkPixbuf* pixbuf = NULL;
if (favicon.width() > 0)
pixbuf = gfx::GdkPixbufFromSkBitmap(&favicon);
gtk_list_store_set(model_, &tree_iter,
COL_FAVICON, favicon.width() > 0
? gfx::GdkPixbufFromSkBitmap(&favicon)
: NULL,
COL_FAVICON, pixbuf,
COL_TITLE, title.c_str(),
-1);
if (pixbuf)
g_object_unref(pixbuf);
}
}
gtk_widget_show_all(GTK_WIDGET(dialog_));
......@@ -223,4 +226,3 @@ void HideForTabContents(TabContents* contents) {
}
} // namespace hung_renderer_dialog
......@@ -241,6 +241,7 @@ void KeywordEditorView::SetColumnValues(int model_row, GtkTreeIter* iter) {
COL_KEYWORD, WideToUTF8(table_model_->GetText(
model_row, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)).c_str(),
-1);
g_object_unref(pixbuf);
}
int KeywordEditorView::GetListStoreRowForModelRow(int model_row) const {
......
......@@ -35,7 +35,8 @@ extern const GdkColor kGdkBlack;
extern const GdkColor kGdkGreen;
// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
// it is an expensive operation.
// it is an expensive operation. The returned GdkPixbuf will have a refcount of
// 1, and the caller is responsible for unrefing it when done.
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap);
// Modify the given region by subtracting the given rectangles.
......
......@@ -220,10 +220,3 @@
fun:ProfileSyncFactoryImpl::CreateProfileSyncService
fun:TestingProfile::CreateProfileSyncService
}
{
bug_38895
Heapcheck:Leak
fun:gfx::GdkPixbufFromSkBitmap
fun:KeywordEditorView::SetColumnValues
}
......@@ -224,6 +224,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
gtk_image_new_from_pixbuf(pixbuf));
g_object_unref(pixbuf);
} else {
menu_item = gtk_menu_item_new_with_mnemonic(label.c_str());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment