[maemo-commits] [maemo-commits] r12523 - in projects/haf/trunk/hildon-fm: . debian hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Jun 28 11:47:41 EEST 2007
Author: richard
Date: 2007-06-28 11:47:28 +0300 (Thu, 28 Jun 2007)
New Revision: 12523

Modified:
   projects/haf/trunk/hildon-fm/ChangeLog
   projects/haf/trunk/hildon-fm/debian/changelog
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
Log:
NB#59429

Modified: projects/haf/trunk/hildon-fm/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-fm/ChangeLog	2007-06-28 08:19:12 UTC (rev 12522)
+++ projects/haf/trunk/hildon-fm/ChangeLog	2007-06-28 08:47:28 UTC (rev 12523)
@@ -1,3 +1,13 @@
+2007-06-27  Carlos Garnacho  <carlos at imendio.com>
+
+	* hildon-fm/hildon-file-system-model.c (struct HandleData)
+	(free_handle_data): Added.
+	(link_file_folder): Pass HandleData to the asynchronous get_folder
+	function. keep a reference to the model for each operation.
+	(get_folder_callback): Release the reference when the operation has
+	been processed. This avoids early model destruction when there are
+	noncancellable operations still alive. (NB#59429)
+
 2007-06-26  Richard Hult  <richard at imendio.com>
 
 	* configure.ac: Bump version.

Modified: projects/haf/trunk/hildon-fm/debian/changelog
===================================================================
--- projects/haf/trunk/hildon-fm/debian/changelog	2007-06-28 08:19:12 UTC (rev 12522)
+++ projects/haf/trunk/hildon-fm/debian/changelog	2007-06-28 08:47:28 UTC (rev 12523)
@@ -2,6 +2,8 @@
 
   * Fixes: NB#59187. File/Folder operations in MMC through PC does not 
     update in MMC.
+  * Fixes: NB#59429. Application crashes on cancelling the 'open image' dialog
+    more than once.
 
  -- Richard Hult <richard at imendio.com>  Tue, 26 Jun 2007 14:32:51 +0200
 

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-06-28 08:19:12 UTC (rev 12522)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-06-28 08:47:28 UTC (rev 12523)
@@ -123,6 +123,11 @@
     gulong volumes_changed_handler;
 };
 
+typedef struct {
+    HildonFileSystemModel *model;
+    GNode *node;
+} HandleData;
+
 /* Property id:s */
 enum {
     PROP_BACKEND = 1,
@@ -1569,23 +1574,35 @@
 }
 
 static void
+free_handle_data (HandleData *handle_data)
+{
+    g_object_unref (handle_data->model);
+    g_slice_free (HandleData, handle_data);
+}
+
+static void
 get_folder_callback (GtkFileSystemHandle *handle,
                      GtkFileFolder *folder,
                      const GError *error,
                      gpointer data)
 {
   gboolean cancelled = handle->cancelled;
-  GNode *node = (GNode *)data;
   HildonFileSystemModelNode *model_node;
   HildonFileSystemModel *model;
+  HandleData *handle_data = (HandleData *) data;
+  GNode *node;
 
   g_object_unref (handle);
 
-  /* When the operation has been cancelled, DATA is no longer valid.
+  /* When the operation has been cancelled, handle_data->node is no longer valid.
    */
   if (cancelled)
-    return;
+    {
+      free_handle_data (handle_data);
+      return;
+    }
 
+  node = handle_data->node;
   model_node = (HildonFileSystemModelNode *) node->data;
   model = model_node->model;
 
@@ -1646,6 +1663,8 @@
 
   if (error)
     handle_load_error (node);
+
+  free_handle_data (handle_data);
 }
 
 static gboolean
@@ -1654,6 +1673,7 @@
   HildonFileSystemModel *model;
   HildonFileSystemModelNode *model_node;
   GtkFileFolder *parent_folder;
+  HandleData *handle_data;
 
   g_assert(node != NULL && path != NULL);
   model_node = node->data;
@@ -1675,6 +1695,13 @@
   parent_folder = (node->parent && node->parent->data) ?
       ((HildonFileSystemModelNode *) node->parent->data)->folder : NULL;
 
+  /* hold a reference to the model, it will be released
+   * when the get_folder operation has finished
+   */
+  handle_data = g_slice_new (HandleData);
+  handle_data->model = g_object_ref (model);
+  handle_data->node = node;
+
   if (model_node->location)
     {
       model_node->get_folder_handle =
@@ -1682,19 +1709,20 @@
           (model_node->location,
            model->priv->filesystem,
            path, GTK_FILE_INFO_ALL,
-           get_folder_callback, node);
+           get_folder_callback, handle_data);
     }
   else
     {
       model_node->get_folder_handle =
         gtk_file_system_get_folder (model->priv->filesystem,
                                     path, GTK_FILE_INFO_ALL,
-                                    get_folder_callback, node);
+                                    get_folder_callback, handle_data);
     }
 
   if (model_node->get_folder_handle == NULL)
     {
       ULOG_ERR_F ("Failed to create monitor for path %s", (char *) path);
+      free_handle_data (handle_data);
       return FALSE;
     }
   else


More information about the maemo-commits mailing list