[gtksourceview/gnome-3-20] view: fix critical message when a NULL StyleScheme is set



commit 5637a18ec55559a82bf27f4701ce9df4648917ed
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jun 12 14:42:41 2016 +0200

    view: fix critical message when a NULL StyleScheme is set
    
    _gtk_source_style_scheme_apply() doesn't accept a NULL StyleScheme,
    which is normal.
    
    Factor out the update_style() function, to avoid code duplication, since
    the code was correct at one place and incorrect at another place.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760984

 gtksourceview/gtksourceview.c |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 2b0db3f..33d3a56 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -5165,13 +5165,10 @@ update_spaces_color (GtkSourceView *view)
 }
 
 static void
-gtk_source_view_realize (GtkWidget *widget)
+update_style (GtkSourceView *view)
 {
-       GtkSourceView *view = GTK_SOURCE_VIEW (widget);
-
-       GTK_WIDGET_CLASS (gtk_source_view_parent_class)->realize (widget);
-
-       if (view->priv->style_scheme != NULL && !view->priv->style_scheme_applied)
+       if (view->priv->style_scheme != NULL &&
+           !view->priv->style_scheme_applied)
        {
                _gtk_source_style_scheme_apply (view->priv->style_scheme, view);
                view->priv->style_scheme_applied = TRUE;
@@ -5184,6 +5181,14 @@ gtk_source_view_realize (GtkWidget *widget)
 }
 
 static void
+gtk_source_view_realize (GtkWidget *widget)
+{
+       GTK_WIDGET_CLASS (gtk_source_view_parent_class)->realize (widget);
+
+       update_style (GTK_SOURCE_VIEW (widget));
+}
+
+static void
 gtk_source_view_update_style_scheme (GtkSourceView *view)
 {
        GtkTextBuffer *buffer;
@@ -5208,18 +5213,11 @@ gtk_source_view_update_style_scheme (GtkSourceView *view)
 
        g_set_object (&view->priv->style_scheme, new_scheme);
 
+       view->priv->style_scheme_applied = FALSE;
+
        if (gtk_widget_get_realized (GTK_WIDGET (view)))
        {
-               _gtk_source_style_scheme_apply (new_scheme, view);
-               update_background_pattern_color (view);
-               update_current_line_color (view);
-               update_right_margin_colors (view);
-               update_spaces_color (view);
-               view->priv->style_scheme_applied = TRUE;
-       }
-       else
-       {
-               view->priv->style_scheme_applied = FALSE;
+               update_style (view);
        }
 }
 


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