зеркало из https://github.com/mozilla/gecko-dev.git
b=451341 make the pointer from MozDrawingarea to MozContainer a weak reference r=roc
This commit is contained in:
Родитель
5420c9c061
Коммит
5e2d6ed15e
|
@ -87,8 +87,6 @@ moz_drawingarea_new (MozDrawingarea *parent, MozContainer *widget_parent,
|
|||
|
||||
drawingarea = g_object_new(MOZ_DRAWINGAREA_TYPE, NULL);
|
||||
|
||||
drawingarea->parent = parent;
|
||||
|
||||
if (!parent)
|
||||
moz_drawingarea_create_windows(drawingarea,
|
||||
GTK_WIDGET(widget_parent)->window,
|
||||
|
@ -126,6 +124,24 @@ moz_drawingarea_reparent (MozDrawingarea *drawingarea, GdkWindow *aNewParent)
|
|||
aNewParent, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
nullify_widget_pointers (gpointer data, GObject *widget)
|
||||
{
|
||||
MozDrawingarea *drawingarea = data;
|
||||
|
||||
#ifdef DEBUG
|
||||
gpointer user_data;
|
||||
/* This function may get called twice before widget is destroyed,
|
||||
so the user_data may have already been nullified. */
|
||||
gdk_window_get_user_data(drawingarea->inner_window, &user_data);
|
||||
if (user_data && widget && user_data != widget)
|
||||
g_critical("user_data does not match widget");
|
||||
#endif
|
||||
|
||||
gdk_window_set_user_data(drawingarea->inner_window, NULL);
|
||||
gdk_window_set_user_data(drawingarea->clip_window, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_create_windows (MozDrawingarea *drawingarea, GdkWindow *parent,
|
||||
GtkWidget *widget, GdkVisual *visual)
|
||||
|
@ -173,6 +189,8 @@ moz_drawingarea_create_windows (MozDrawingarea *drawingarea, GdkWindow *parent,
|
|||
&attributes, attributes_mask);
|
||||
gdk_window_set_user_data(drawingarea->inner_window, widget);
|
||||
|
||||
g_object_weak_ref(G_OBJECT(widget), nullify_widget_pointers, drawingarea);
|
||||
|
||||
/* set the default pixmap to None so that you don't end up with the
|
||||
gtk default which is BlackPixel. */
|
||||
gdk_window_set_back_pixmap(drawingarea->inner_window, NULL, FALSE);
|
||||
|
@ -186,14 +204,19 @@ void
|
|||
moz_drawingarea_finalize (GObject *object)
|
||||
{
|
||||
MozDrawingarea *drawingarea;
|
||||
gpointer user_data;
|
||||
|
||||
g_return_if_fail(IS_MOZ_DRAWINGAREA(object));
|
||||
|
||||
drawingarea = MOZ_DRAWINGAREA(object);
|
||||
|
||||
gdk_window_set_user_data(drawingarea->inner_window, NULL);
|
||||
gdk_window_get_user_data(drawingarea->inner_window, &user_data);
|
||||
if (user_data) {
|
||||
g_object_weak_unref(user_data, nullify_widget_pointers, drawingarea);
|
||||
nullify_widget_pointers(drawingarea, NULL);
|
||||
}
|
||||
|
||||
gdk_window_destroy(drawingarea->inner_window);
|
||||
gdk_window_set_user_data(drawingarea->clip_window, NULL);
|
||||
gdk_window_destroy(drawingarea->clip_window);
|
||||
|
||||
(* parent_class->finalize) (object);
|
||||
|
|
|
@ -67,7 +67,6 @@ struct _MozDrawingarea
|
|||
GObject parent_instance;
|
||||
GdkWindow *clip_window;
|
||||
GdkWindow *inner_window;
|
||||
MozDrawingarea *parent;
|
||||
};
|
||||
|
||||
struct _MozDrawingareaClass
|
||||
|
|
Загрузка…
Ссылка в новой задаче