fixed memory leaks and double dbus events
authorVlad <vlad@gas.by>
Mon, 26 Jul 2010 10:27:19 +0000 (13:27 +0300)
committerVlad <vlad@gas.by>
Mon, 26 Jul 2010 10:27:19 +0000 (13:27 +0300)
applet/src/livewp-dbus.c
applet/src/livewp-home-widget.c
applet/src/livewp-main.c

index b799307..e28ea36 100644 (file)
@@ -49,6 +49,7 @@ livewp_initialize_dbus(Animation_WallpaperPrivate *priv){
         dbus_connection_add_filter(priv->dbus_conn_session,
                                    (DBusHandleMessageFunction)get_livewp_signal_cb,
                                    priv, NULL);
+#if 0
        filter_string =
             g_strdup_printf("type='signal', interface='%s'", NOTIFY_SIGNAL_INTERFACE);
         dbus_bus_add_match(priv->dbus_conn_session, filter_string, &error);
@@ -61,6 +62,7 @@ livewp_initialize_dbus(Animation_WallpaperPrivate *priv){
         dbus_connection_add_filter(priv->dbus_conn_session,
                                    (DBusHandleMessageFunction)get_livewp_signal_cb,
                                    priv, NULL);
+#endif
 
     }
 }
@@ -141,13 +143,29 @@ get_livewp_signal_cb(DBusConnection *conn, DBusMessage *msg, Animation_Wallpaper
     START_FUNCTION;
 #endif
 
-/*    fprintf (stderr, "PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg)); */
+#if 0
+#if  defined APPLICATION 
+    fprintf (stderr, "APPLICATION PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg)); 
+#endif
+
+#if  defined CONTROLPANEL
+    fprintf (stderr, "APPLICATION PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg)); 
+#endif
+
+#if !(defined CONTROLPANEL || defined APPLICATION) 
+    fprintf (stderr, "APPLET PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg)); 
+#endif
+#endif
+
+    if (!priv)
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
     if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_RELOAD_CONFIG)){
         if(read_config(priv)){
                 fprintf(stderr, "\nCan not read config file.\n");
         }else{
             read_config(priv);
-#if  !(defined APPLICATION || defined CONTROLPANEL)
+#if  defined APPLICATION 
             reload_scene(priv->desktop_plugin);
 #endif
         }
index f5e1440..68077a1 100644 (file)
@@ -578,7 +578,7 @@ animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
     gobject_class->destroy = (gpointer)lw_applet_finalize;
     object_class->finalize = desktop_widget_finalize;
     widget_class->realize = lw_applet_realize;
-    widget_class->expose_event = lw_applet_expose_event;
+//    widget_class->expose_event = lw_applet_expose_event;
 
     g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
 
index b16b15f..e248337 100644 (file)
@@ -96,8 +96,13 @@ view_changed (GConfClient *client, guint cnxn_id,
 void
 quit_from_program (Animation_WallpaperPrivate *priv)
 {
+     fprintf(stderr,"quit_from_program\n");
      if (priv){
             livewp_deinitialize_dbus(priv);
+         if (priv->view_notify != 0) { 
+            gconf_client_notify_remove (gconf_client_get_default (), priv->view_notify);
+            priv->view_notify = 0;
+         }
             if (priv->long_timer){
                    g_source_remove(priv->long_timer);
                priv->long_timer = 0;
@@ -107,8 +112,12 @@ quit_from_program (Animation_WallpaperPrivate *priv)
                    priv->short_timer = 0;
             }
             destroy_scene(priv->desktop_plugin);
-         if (priv->view_notify != 0)                                                                                                                                   
-            gconf_client_notify_remove (gconf_client_get_default (), priv->view_notify);
+         osso_deinitialize(priv->osso);
+         g_hash_table_destroy(priv->hash_scene_func);
+         g_free(priv->desktop_plugin);
+         priv->desktop_plugin = NULL;
+         g_free(priv);
+         priv = NULL;
      }
      gtk_main_quit();;
 }
@@ -117,9 +126,6 @@ int
 main(int argc, char *argv[])
 {
     GtkWidget *main_widget = NULL;
-    GtkWidget *window;
-    GtkWidget *btn_setting, *vbox, *btn_power;
-    gint result;
     HildonProgram       *app;
     int view = 1;
 
@@ -181,11 +187,12 @@ main(int argc, char *argv[])
     fprintf(stderr,"VISIBLE %i %i\n",priv->visible, current_active_view());
     gconf_client_add_dir(gconf_client_get_default (), "/apps/osso/hildon-desktop/views", GCONF_CLIENT_PRELOAD_NONE, NULL);
     priv->view_notify = gconf_client_notify_add(gconf_client_get_default (),"/apps/osso/hildon-desktop/views/current",
-                                                view_changed, priv, NULL, NULL);
+                                                (GConfClientNotifyFunc)view_changed, priv, NULL, NULL);
 
     init_scene_theme(desktop_plugin);
         
     priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
 
     gtk_main();
+    return 0;
 }