[gnome-devel-docs] menubar.c : fix GError usage



commit 5140505766357fb61b55f856f7800990ea214dbe
Author: Manuel Bachmann <tarnyko tarnyko net>
Date:   Mon Dec 9 00:43:56 2013 +0100

    menubar.c : fix GError usage
    
    GError condition was always verified, and eventually leaked
    memory.

 platform-demos/C/samples/menubar.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/platform-demos/C/samples/menubar.c b/platform-demos/C/samples/menubar.c
index a350bf7..ff2f4a9 100644
--- a/platform-demos/C/samples/menubar.c
+++ b/platform-demos/C/samples/menubar.c
@@ -235,7 +235,7 @@ startup (GApplication *app,
 
   GtkBuilder *builder;
 
-  GError **error;
+  GError *error = NULL;
 
   /* Begin creating the "new" action.
    * Note that it is an action without a state.
@@ -279,9 +279,10 @@ startup (GApplication *app,
    * this to work. The function used here returns a value within our variable
    * "error", and it is equal to zero if an error is indeed found.
    */
-  gtk_builder_add_from_file (builder, "menubar.ui", error);
-  if (error == 0) {
+  gtk_builder_add_from_file (builder, "menubar.ui", &error);
+  if (error != NULL) {
      g_print ("File not found.\n");
+     g_error_free (error);
   }
 
   /* Extract the menubar */


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