[gtk+] Don't assume a screen exists before realize()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Don't assume a screen exists before realize()
- Date: Sat, 5 Feb 2011 03:06:42 +0000 (UTC)
commit 4dc9b294d8a5bd822828964930b834f4b8999cff
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 4 22:01:40 2011 -0500
Don't assume a screen exists before realize()
Fix for https://bugzilla.gnome.org/show_bug.cgi?id=641429
gtk/gtkstyle.c | 9 +++++----
gtk/gtkstylecontext.c | 2 +-
gtk/gtkwidget.c | 2 +-
gtk/gtkwindow.c | 20 +++++++++++---------
4 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 81105d8..5347119 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -813,13 +813,15 @@ gtk_style_copy (GtkStyle *style)
GtkStyle*
_gtk_style_new_for_path (GdkScreen *screen,
- GtkWidgetPath *path)
+ GtkWidgetPath *path)
{
GtkStyleContext *context;
GtkStyle *style;
context = gtk_style_context_new ();
- gtk_style_context_set_screen (context, screen);
+
+ if (screen)
+ gtk_style_context_set_screen (context, screen);
gtk_style_context_set_path (context, path);
style = g_object_new (GTK_TYPE_STYLE,
@@ -848,8 +850,7 @@ gtk_style_new (void)
path = gtk_widget_path_new ();
gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
- style = _gtk_style_new_for_path (gdk_screen_get_default (),
- path);
+ style = _gtk_style_new_for_path (gdk_screen_get_default (), path);
gtk_widget_path_free (path);
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 7cd0dab..6eed378 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2617,7 +2617,7 @@ gtk_style_context_set_screen (GtkStyleContext *context,
GtkStyleContextPrivate *priv;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- g_return_if_fail (GDK_IS_SCREEN (screen));
+ g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
priv = context->priv;
if (priv->screen == screen)
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 74d83f2..f7e5383 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -14179,7 +14179,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
G_CALLBACK (style_context_changed), widget);
gtk_style_context_set_screen (widget->priv->context,
- gtk_widget_get_screen (widget));
+ gtk_widget_get_screen_unchecked (widget));
_gtk_widget_update_path (widget);
gtk_style_context_set_path (widget->priv->context,
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5696c19..7336d02 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1108,8 +1108,9 @@ gtk_window_init (GtkWindow *window)
priv->has_user_ref_count = TRUE;
toplevel_list = g_slist_prepend (toplevel_list, window);
- g_signal_connect (priv->screen, "composited-changed",
- G_CALLBACK (gtk_window_on_composited_changed), window);
+ if (priv->screen)
+ g_signal_connect (priv->screen, "composited-changed",
+ G_CALLBACK (gtk_window_on_composited_changed), window);
}
static void
@@ -7961,7 +7962,7 @@ gtk_window_set_screen (GtkWindow *window,
GtkWidget *widget;
GdkScreen *previous_screen;
gboolean was_mapped;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (GDK_IS_SCREEN (screen));
@@ -7979,17 +7980,18 @@ gtk_window_set_screen (GtkWindow *window,
gtk_widget_unmap (widget);
if (gtk_widget_get_realized (widget))
gtk_widget_unrealize (widget);
-
+
gtk_window_free_key_hash (window);
priv->screen = screen;
gtk_widget_reset_rc_styles (widget);
if (screen != previous_screen)
{
- g_signal_handlers_disconnect_by_func (previous_screen,
- gtk_window_on_composited_changed, window);
- g_signal_connect (screen, "composited-changed",
- G_CALLBACK (gtk_window_on_composited_changed), window);
-
+ if (previous_screen)
+ g_signal_handlers_disconnect_by_func (previous_screen,
+ gtk_window_on_composited_changed, window);
+ g_signal_connect (screen, "composited-changed",
+ G_CALLBACK (gtk_window_on_composited_changed), window);
+
_gtk_widget_propagate_screen_changed (widget, previous_screen);
_gtk_widget_propagate_composited_changed (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]