diff src/aosd/aosd.c @ 638:7c569af3f656 trunk

[svn] - aosd: prevent aosd_cleanup from freeing stuff if aosd_init has never been called, closes bug #790
author giacomo
date Mon, 12 Feb 2007 08:02:53 -0800
parents 1708b03e116c
children 153bb82ff081
line wrap: on
line diff
--- a/src/aosd/aosd.c	Mon Feb 12 07:20:56 2007 -0800
+++ b/src/aosd/aosd.c	Mon Feb 12 08:02:53 2007 -0800
@@ -26,6 +26,7 @@
 
 
 aosd_cfg_t * global_config = NULL;
+static gboolean plugin_is_active = FALSE;
 
 
 /* ***************** */
@@ -40,6 +41,7 @@
 void
 aosd_init ( void )
 {
+  plugin_is_active = TRUE;
   g_log_set_handler( NULL , G_LOG_LEVEL_WARNING , g_log_default_handler , NULL );
 
   global_config = aosd_cfg_new();
@@ -54,16 +56,21 @@
 void
 aosd_cleanup ( void )
 {
-  aosd_trigger_stop( &global_config->osd->trigger );
+  if ( plugin_is_active == TRUE )
+  {
+    aosd_trigger_stop( &global_config->osd->trigger );
 
-  aosd_shutdown();
+    aosd_shutdown();
 
-  if ( global_config != NULL )
-  {
-    aosd_cfg_delete( global_config );
-    global_config = NULL;
+    if ( global_config != NULL )
+    {
+      aosd_cfg_delete( global_config );
+      global_config = NULL;
+    }
+    
+    plugin_is_active = FALSE;
   }
-
+  
   return;
 }