[gnac/devel] Added safety checks in destroy functions



commit fdd4884c341d54cd99ebe275da72668e4e01ae07
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Tue Sep 14 16:54:05 2010 +0100

    Added safety checks in destroy functions

 src/gnac-gconf.c |    2 +-
 src/gnac-main.c  |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/gnac-gconf.c b/src/gnac-gconf.c
index c5a10e4..a7c2bdc 100644
--- a/src/gnac-gconf.c
+++ b/src/gnac-gconf.c
@@ -70,7 +70,7 @@ gnac_gconf_init(void)
 void
 gnac_gconf_destroy(void)
 {
-  g_object_unref(gconf_client);
+  if (gconf_client) g_object_unref(gconf_client);
 }
 
 
diff --git a/src/gnac-main.c b/src/gnac-main.c
index bb3cac2..2c1403c 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -474,8 +474,8 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
 
   }
 
-  g_object_unref(converter);
-  g_object_unref(metadata);
+  if (converter) g_object_unref(converter);
+  if (metadata) g_object_unref(metadata);
 
   gnac_gconf_destroy();
   gnac_properties_destroy();
@@ -483,7 +483,8 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
   gnac_profiles_destroy();
   gnac_ui_destroy();
 
-  gtk_main_quit();
+  /* only call 'gtk_main_quit' if the main loop is running */
+  if (gtk_main_level() != 0) gtk_main_quit();
 
   return FALSE;
 }



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