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

Unified Diff: chrome/browser/gtk/rounded_window.cc

Issue 1783010: GTK: more signal handler foolproofing. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 8 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 | « chrome/browser/gtk/options/content_page_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/rounded_window.cc
diff --git a/chrome/browser/gtk/rounded_window.cc b/chrome/browser/gtk/rounded_window.cc
index 52bedc95a1d36d0f404b3e39fa1c8e6a46e80782..c223425f63c3df9fb0a9621d94ed9b8ffe879ee1 100644
--- a/chrome/browser/gtk/rounded_window.cc
+++ b/chrome/browser/gtk/rounded_window.cc
@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
#include <math.h>
+#include "app/gtk_signal.h"
#include "base/i18n/rtl.h"
#include "chrome/browser/gtk/gtk_util.h"
@@ -36,6 +37,9 @@ struct RoundedWindowData {
// Which sides of the window should have an internal border?
int drawn_borders;
+
+ // Keeps track of attached signal handlers.
+ GtkSignalRegistrar signals;
};
// Callback from GTK to release allocated memory.
@@ -256,11 +260,12 @@ void ActAsRoundedWindow(
DCHECK(!g_object_get_data(G_OBJECT(widget), kRoundedData));
gtk_widget_set_app_paintable(widget, TRUE);
- g_signal_connect(widget, "expose-event",
- G_CALLBACK(OnRoundedWindowExpose), NULL);
- g_signal_connect(widget, "style-set", G_CALLBACK(OnStyleSet), NULL);
RoundedWindowData* data = new RoundedWindowData;
+ data->signals.Connect(widget, "expose-event",
+ G_CALLBACK(OnRoundedWindowExpose), NULL);
+ data->signals.Connect(widget, "style-set", G_CALLBACK(OnStyleSet), NULL);
+
data->expected_width = -1;
data->expected_height = -1;
@@ -275,13 +280,7 @@ void ActAsRoundedWindow(
}
void StopActingAsRoundedWindow(GtkWidget* widget) {
- g_signal_handlers_disconnect_by_func(widget,
- reinterpret_cast<gpointer>(OnRoundedWindowExpose), NULL);
- g_signal_handlers_disconnect_by_func(widget,
- reinterpret_cast<gpointer>(OnStyleSet), NULL);
-
- delete static_cast<RoundedWindowData*>(
- g_object_steal_data(G_OBJECT(widget), kRoundedData));
+ g_object_set_data(G_OBJECT(widget), kRoundedData, NULL);
if (GTK_WIDGET_REALIZED(widget))
gdk_window_shape_combine_mask(widget->window, NULL, 0, 0);
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698