fixed varios memory leaks
authorVlad Vasiliev <vlad@toshiba2.oblgaz>
Sun, 11 Apr 2010 19:19:04 +0000 (22:19 +0300)
committerVlad Vasiliev <vlad@toshiba2.oblgaz>
Sun, 11 Apr 2010 19:19:04 +0000 (22:19 +0300)
applet/src/livewp-home-widget.c

index e25acb1..59472f0 100644 (file)
@@ -236,6 +236,8 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
                 actor->visible = TRUE;
                 phase = get_moon_phase();
                 newfile = g_strdup_printf( "%s%d.png", actor->name, phase);
+                if (actor->filename)
+                    g_free(actor->filename);
                 actor->filename = newfile;
                 create_hildon_actor(actor, desktop_plugin);
 
@@ -304,10 +306,15 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (daytime == TIME_NIGHT){
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("tram_dark.png");
-        else
+        } else{
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("tram.png");
+        }
         create_hildon_actor(actor, desktop_plugin);
     }
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
@@ -345,10 +352,15 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (daytime == TIME_NIGHT){
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("tu154.png");
-        else
+        }else{
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("tu154.png");
+        }
         create_hildon_actor(actor, desktop_plugin);
     }
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
@@ -387,10 +399,15 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (daytime == TIME_NIGHT){
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("plane3.png");
-        else
+        }else{
+            if (actor->filename)
+                g_free(actor->filename);
             actor->filename = g_strdup("plane3.png");
+        }
         create_hildon_actor(actor, desktop_plugin);
     }
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
@@ -415,7 +432,7 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
   GtkWidget *ha = NULL;
   GdkPixbuf *pixbuf = NULL;
   GtkWidget *image = NULL;
-  gchar *str;
+  gchar     *str = NULL;
 
   /* fprintf(stderr, "create_hildon_actor %s\n", actor->name);*/
   ha = hildon_animation_actor_new();
@@ -425,6 +442,8 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
                                              actor->width, 
                                              actor->height, 
                                              NULL);
+  if (str)
+      g_free(str);
   if (pixbuf){
       image = gtk_image_new_from_pixbuf (pixbuf);
       g_object_unref(G_OBJECT(pixbuf));
@@ -464,7 +483,7 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
 {
     GtkWidget *image = NULL;
     GdkPixbuf *pixbuf = NULL;
-    gchar *str;
+    gchar     *str = NULL;
 
     str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
                             desktop_plugin->priv->theme, actor->filename);
@@ -473,6 +492,8 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
                                                actor->width, 
                                                actor->height, 
                                                NULL);
+    if(str)
+        g_free(str);
     if (pixbuf){
         image = gtk_image_new_from_pixbuf (pixbuf);
         g_object_unref(G_OBJECT(pixbuf));
@@ -500,6 +521,8 @@ change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
     if (!actor) return;
     daytime = get_daytime();
     newfile = g_strdup_printf("%s%d.png", actor->name, daytime); 
+    if (actor->filename)
+            g_free(actor->filename);
     actor->filename = newfile;
     change_hildon_actor(actor, desktop_plugin);
 }
@@ -520,6 +543,10 @@ destroy_scene(void){
     while (tmp != NULL){
         actor = tmp->data;
         if (actor){
+            if (actor->filename)
+                g_free(actor->filename);
+            if (actor->name)
+                g_free(actor->name);
             gtk_widget_destroy(actor->widget);
             //actor->widget = NULL;
             g_free(actor);