[gtk+] widget: Don't create the style context if not necessary



commit 757087e9b47229930f4b302adc20e966978023a1
Author: Benjamin Otte <otte redhat com>
Date:   Sat Mar 26 15:22:11 2011 +0100

    widget: Don't create the style context if not necessary
    
    If all we want to do is update the context's screen, we don't need to
    create it if it doesn't exist yet.

 gtk/gtkwidget.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index bcbb91a..f52ac29 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8529,7 +8529,7 @@ do_screen_change (GtkWidget *widget,
 {
   if (old_screen != new_screen)
     {
-      GtkStyleContext *context;
+      GtkWidgetPrivate *priv = widget->priv;
 
       if (old_screen)
 	{
@@ -8540,8 +8540,8 @@ do_screen_change (GtkWidget *widget,
 
       _gtk_tooltip_hide (widget);
 
-      context = gtk_widget_get_style_context (widget);
-      gtk_style_context_set_screen (context, gtk_widget_get_screen (widget));
+      if (new_screen && priv->context)
+        gtk_style_context_set_screen (priv->context, new_screen);
 
       g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]