Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2960)

Unified Diff: chrome/browser/ui/gtk/theme_service_gtk.cc

Issue 9855028: gtk: Fix memory leak in ThemeServiceGtk::LoadGtkValues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: erg review -> is_default_link_color bool variable Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/theme_service_gtk.cc
diff --git a/chrome/browser/ui/gtk/theme_service_gtk.cc b/chrome/browser/ui/gtk/theme_service_gtk.cc
index 7c50f6e888fc95ca30898d03d4b87433edf5ff1a..733eaf3feb56edd1203d59b12c69c14455ba8a8f 100644
--- a/chrome/browser/ui/gtk/theme_service_gtk.cc
+++ b/chrome/browser/ui/gtk/theme_service_gtk.cc
@@ -766,8 +766,12 @@ void ThemeServiceGtk::LoadGtkValues() {
const GdkColor* link_color = NULL;
gtk_widget_style_get(GTK_WIDGET(fake_window_),
"link-color", &link_color, NULL);
- if (!link_color)
+
+ bool is_default_link_color = false;
+ if (!link_color) {
link_color = &kDefaultLinkColor;
+ is_default_link_color = true;
+ }
SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK,
link_color);
@@ -778,6 +782,9 @@ void ThemeServiceGtk::LoadGtkValues() {
SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE,
link_color);
+ if (link_color && !is_default_link_color)
+ gdk_color_free(const_cast<GdkColor*>(link_color));
+
// Generate the colors that we pass to WebKit.
focus_ring_color_ = gfx::GdkColorToSkColor(frame_color);
GdkColor thumb_active_color, thumb_inactive_color, track_color;
@@ -801,10 +808,10 @@ void ThemeServiceGtk::LoadGtkValues() {
}
GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
- const GdkColor* theme_frame = NULL;
- const GdkColor* theme_inactive_frame = NULL;
- const GdkColor* theme_incognito_frame = NULL;
- const GdkColor* theme_incognito_inactive_frame = NULL;
+ GdkColor* theme_frame = NULL;
+ GdkColor* theme_inactive_frame = NULL;
+ GdkColor* theme_incognito_frame = NULL;
+ GdkColor* theme_incognito_inactive_frame = NULL;
gtk_widget_style_get(GTK_WIDGET(fake_frame_),
"frame-color", &theme_frame,
"inactive-frame-color", &theme_inactive_frame,
@@ -819,6 +826,8 @@ GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
kDefaultFrameShift,
ThemeService::COLOR_FRAME,
ThemeService::TINT_FRAME);
+ if (theme_frame)
+ gdk_color_free(theme_frame);
SetThemeTintFromGtk(ThemeService::TINT_BACKGROUND_TAB, &frame_color);
BuildAndSetFrameColor(
@@ -827,6 +836,8 @@ GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
kDefaultFrameShift,
ThemeService::COLOR_FRAME_INACTIVE,
ThemeService::TINT_FRAME_INACTIVE);
+ if (theme_inactive_frame)
+ gdk_color_free(theme_inactive_frame);
BuildAndSetFrameColor(
&frame_color,
@@ -834,6 +845,8 @@ GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO),
ThemeService::COLOR_FRAME_INCOGNITO,
ThemeService::TINT_FRAME_INCOGNITO);
+ if (theme_incognito_frame)
+ gdk_color_free(theme_incognito_frame);
BuildAndSetFrameColor(
&frame_color,
@@ -841,6 +854,8 @@ GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO_INACTIVE),
ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE,
ThemeService::TINT_FRAME_INCOGNITO_INACTIVE);
+ if (theme_incognito_inactive_frame)
+ gdk_color_free(theme_incognito_inactive_frame);
return frame_color;
}
@@ -993,7 +1008,7 @@ SkBitmap* ThemeServiceGtk::GenerateFrameImage(
gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true);
int gradient_size;
- const GdkColor* gradient_top_color = NULL;
+ GdkColor* gradient_top_color = NULL;
gtk_widget_style_get(GTK_WIDGET(fake_frame_),
"frame-gradient-size", &gradient_size,
gradient_name, &gradient_top_color,
@@ -1002,6 +1017,8 @@ SkBitmap* ThemeServiceGtk::GenerateFrameImage(
SkColor lighter = gradient_top_color ?
gfx::GdkColorToSkColor(*gradient_top_color) :
color_utils::HSLShift(base, kGtkFrameShift);
+ if (gradient_top_color)
+ gdk_color_free(gradient_top_color);
SkShader* shader = gfx::CreateGradientShader(
0, gradient_size, lighter, base);
SkPaint paint;
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698