[brasero/gnome-2-28] Instead of crashing when brasero_burn_library_start () has not been called, abort with an error mess



commit 901bbae512c1bdffd767603f653005ac6551b74a
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu Sep 24 14:32:11 2009 +0200

    Instead of crashing when brasero_burn_library_start () has not been called, abort with an error message

 libbrasero-burn/burn-basics.c |   21 +++++++++++++++++++--
 libbrasero-burn/burn-caps.c   |   14 --------------
 2 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/libbrasero-burn/burn-basics.c b/libbrasero-burn/burn-basics.c
index 17cab17..d82cca2 100644
--- a/libbrasero-burn/burn-basics.c
+++ b/libbrasero-burn/burn-basics.c
@@ -55,6 +55,7 @@
 
 static BraseroPluginManager *plugin_manager = NULL;
 static BraseroMediumMonitor *medium_manager = NULL;
+static BraseroBurnCaps *default_caps = NULL;
 
 
 GQuark
@@ -215,7 +216,7 @@ brasero_burn_library_start (int *argc,
 			  BRASERO_SUB);
 
 #if defined(HAVE_STRUCT_USCSI_CMD)
-	/* Work around: because on OpenSolaris brasero posiblely be run
+	/* Work around: because on OpenSolaris brasero possibly be run
 	 * as root for a user with 'Primary Administrator' profile,
 	 * a root dbus session will be autospawned at that time.
 	 * This fix is to work around
@@ -250,7 +251,8 @@ brasero_burn_library_start (int *argc,
 		medium_manager = brasero_medium_monitor_get_default ();
 
 	/* initialize plugins */
-	brasero_burn_caps_get_default ();
+	if (!default_caps)
+		default_caps = BRASERO_BURNCAPS (g_object_new (BRASERO_TYPE_BURNCAPS, NULL));
 
 	if (!plugin_manager)
 		plugin_manager = brasero_plugin_manager_get_default ();
@@ -259,6 +261,16 @@ brasero_burn_library_start (int *argc,
 	return TRUE;
 }
 
+BraseroBurnCaps *
+brasero_burn_caps_get_default ()
+{
+	if (!default_caps)
+		g_error ("You must call brasero_burn_library_start () before using API from libbrasero-burn");
+
+	g_object_ref (default_caps);
+	return default_caps;
+}
+
 /**
  * brasero_burn_library_get_plugins_list:
  * 
@@ -290,6 +302,11 @@ brasero_burn_library_stop (void)
 		medium_manager = NULL;
 	}
 
+	if (default_caps) {
+		g_object_unref (default_caps);
+		default_caps = NULL;
+	}
+
 	/* Cleanup the io thing */
 	brasero_io_shutdown ();
 
diff --git a/libbrasero-burn/burn-caps.c b/libbrasero-burn/burn-caps.c
index fe9e7dc..e11bcfb 100644
--- a/libbrasero-burn/burn-caps.c
+++ b/libbrasero-burn/burn-caps.c
@@ -58,7 +58,6 @@
 G_DEFINE_TYPE (BraseroBurnCaps, brasero_burn_caps, G_TYPE_OBJECT);
 
 static GObjectClass *parent_class = NULL;
-static BraseroBurnCaps *default_caps = NULL;
 
 
 static void
@@ -214,8 +213,6 @@ brasero_burn_caps_finalize (GObject *object)
 
 	cobj = BRASERO_BURNCAPS (object);
 	
-	default_caps = NULL;
-
 	if (cobj->priv->groups) {
 		g_hash_table_destroy (cobj->priv->groups);
 		cobj->priv->groups = NULL;
@@ -250,14 +247,3 @@ brasero_burn_caps_init (BraseroBurnCaps *obj)
 							NULL);
 	g_object_unref (client);
 }
-
-BraseroBurnCaps *
-brasero_burn_caps_get_default ()
-{
-	if (!default_caps) 
-		default_caps = BRASERO_BURNCAPS (g_object_new (BRASERO_TYPE_BURNCAPS, NULL));
-	else
-		g_object_ref (default_caps);
-
-	return default_caps;
-}



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