[frogr] Fixed memory management issue in FrogrPictureLoader
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Fixed memory management issue in FrogrPictureLoader
- Date: Mon, 9 Apr 2012 02:08:52 +0000 (UTC)
commit dcf4c7534868686d4ebe3a04bddd63239e03992a
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Mon Apr 9 03:56:47 2012 +0200
Fixed memory management issue in FrogrPictureLoader
src/frogr-main-view.c | 1 +
src/frogr-picture-loader.c | 17 +++++++++++------
src/main.c | 9 +++------
3 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 76c4d74..02504d4 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -842,6 +842,7 @@ _add_pictures_dialog_response_cb (GtkDialog *dialog, gint response, gpointer dat
if (fileuris != NULL)
{
_load_pictures (FROGR_MAIN_VIEW (self), fileuris);
+ g_slist_foreach (fileuris, (GFunc) g_free, NULL);
g_slist_free (fileuris);
}
}
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index b2e7a42..250e2af 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -652,14 +652,19 @@ frogr_picture_loader_new (GSList *file_uris,
FrogrPicturesLoadedCallback pictures_loaded_cb,
gpointer object)
{
- FrogrPictureLoader *self =
- FROGR_PICTURE_LOADER (g_object_new(FROGR_TYPE_PICTURE_LOADER, NULL));
+ FrogrPictureLoader *self = NULL;
+ FrogrPictureLoaderPrivate *priv = NULL;
+ GSList *uri = NULL;
- FrogrPictureLoaderPrivate *priv =
- FROGR_PICTURE_LOADER_GET_PRIVATE (self);
+ self = FROGR_PICTURE_LOADER (g_object_new(FROGR_TYPE_PICTURE_LOADER, NULL));
+ priv = FROGR_PICTURE_LOADER_GET_PRIVATE (self);
+
+ /* We need to gain ownership of the strings */
+ for (uri = file_uris; uri; uri = g_slist_next (uri))
+ priv->file_uris = g_slist_prepend (priv->file_uris, g_strdup ((gchar *)uri->data));
+ priv->file_uris = g_slist_reverse (priv->file_uris);
- /* Internal data */
- priv->file_uris = g_slist_copy (file_uris);
+ /* Other internal data */
priv->current = priv->file_uris;
priv->index = 0;
priv->n_pictures = g_slist_length (priv->file_uris);
diff --git a/src/main.c b/src/main.c
index 6719e0b..94dad7f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -72,6 +72,9 @@ _load_pictures_on_idle (gpointer data)
frogr_controller_load_pictures (fcontroller, fileuris);
+ g_slist_foreach (fileuris, (GFunc)g_free, NULL);
+ g_slist_free (fileuris);
+
return FALSE;
}
@@ -109,12 +112,6 @@ main (int argc, char **argv)
frogr_controller_run_app (fcontroller);
- if (fileuris)
- {
- g_slist_foreach (fileuris, (GFunc)g_free, NULL);
- g_slist_free (fileuris);
- }
-
/* cleanup libxml2 library */
xmlCleanupParser();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]