[gtk+/parser: 55/74] cssprovider: More error handling into load_internal()



commit 50160ba624b95538c2ae5d801a4ad690304edf8b
Author: Benjamin Otte <otte redhat com>
Date:   Mon Apr 11 19:57:42 2011 +0200

    cssprovider: More error handling into load_internal()
    
    Now the parsing functions starting at parse_stylesheet() don't have to
    care about errors anymore.

 gtk/gtkcssprovider.c |   55 ++++++++++++++++++++++---------------------------
 1 files changed, 25 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index ec0a558..fa75c1e 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2591,21 +2591,10 @@ gtk_css_provider_propagate_error (GtkCssProvider  *provider,
   g_prefix_error (propagate_to, "%s:%u:%u: ", path ? path : "<unknown>", line, position);
 }
 
-static gboolean
+static void
 parse_stylesheet (GtkCssProvider  *css_provider,
-                  GScanner        *scanner,
-                  GError         **error)
+                  GScanner        *scanner)
 {
-  gulong error_handler;
-
-  if (error)
-    error_handler = g_signal_connect (css_provider,
-                                      "parsing-error",
-                                      G_CALLBACK (gtk_css_provider_propagate_error),
-                                      error);
-  else
-    error_handler = 0; /* silence gcc */
-
   g_scanner_get_next_token (scanner);
 
   while (!g_scanner_eof (scanner))
@@ -2627,20 +2616,6 @@ parse_stylesheet (GtkCssProvider  *css_provider,
       
       gtk_css_scanner_reset (scanner);
     }
-
-  if (error)
-    {
-      g_signal_handler_disconnect (css_provider, error_handler);
-      
-      if (*error)
-        {
-          /* We clear all contents from the provider for backwards compat reasons */
-          gtk_css_provider_reset (css_provider);
-          return FALSE;
-        }
-    }
-
-  return TRUE;
 }
 
 static gboolean
@@ -2651,15 +2626,35 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
                                 GError        **error)
 {
   GScanner *scanner;
-  gboolean result;
+  gulong error_handler;
+
+  if (error)
+    error_handler = g_signal_connect (css_provider,
+                                      "parsing-error",
+                                      G_CALLBACK (gtk_css_provider_propagate_error),
+                                      error);
+  else
+    error_handler = 0; /* silence gcc */
 
   scanner = gtk_css_scanner_new (file, data, length);
 
-  result = parse_stylesheet (css_provider, scanner, error);
+  parse_stylesheet (css_provider, scanner);
 
   gtk_css_scanner_destroy (scanner);
 
-  return result;
+  if (error)
+    {
+      g_signal_handler_disconnect (css_provider, error_handler);
+      
+      if (*error)
+        {
+          /* We clear all contents from the provider for backwards compat reasons */
+          gtk_css_provider_reset (css_provider);
+          return FALSE;
+        }
+    }
+
+  return TRUE;
 }
 
 /**



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