[Xfce4-commits] <thunar:master> Unref async file and do some additional checks.

Nick Schermer noreply at xfce.org
Sat Oct 13 16:12:37 CEST 2012


Updating branch refs/heads/master
         to 91d25840bfd7045941317db76c6f9fa7c56fac5d (commit)
       from 315950fe7fbf9de3386c43cf469b1e0427cbe89d (commit)

commit 91d25840bfd7045941317db76c6f9fa7c56fac5d
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Oct 13 11:03:59 2012 +0200

    Unref async file and do some additional checks.

 thunar/thunar-file.c |   11 +++++++++++
 thunar/thunar-file.h |    4 +++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 220e6a0..91836b0 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -842,12 +842,19 @@ thunar_file_get_async_finish (GObject      *object,
 
   /* insert the file into the cache */
   G_LOCK (file_cache_mutex);
+#ifdef G_ENABLE_DEBUG
+  /* check if there is no instance created in the meantime */
+  _thunar_assert (g_hash_table_lookup (file_cache, file->gfile) == NULL);
+#endif
   g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
   G_UNLOCK (file_cache_mutex);
 
   /* pass the loaded file and possible errors to the return function */
   (data->func) (location, file, error, data->user_data);
 
+  /* release the file, see description in ThunarFileGetFunc */
+  g_object_unref (file);
+
   /* free the error, if there is any */
   if (error != NULL)
     g_error_free (error);
@@ -958,6 +965,10 @@ thunar_file_get (GFile   *gfile,
         {
           /* insert the file into the cache */
           G_LOCK (file_cache_mutex);
+#ifdef G_ENABLE_DEBUG
+          /* check if there is no instance created in the meantime */
+          _thunar_assert (g_hash_table_lookup (file_cache, file->gfile) == NULL);
+#endif
           g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
           G_UNLOCK (file_cache_mutex);
         }
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 5d0c03c..8ed87d0 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -103,7 +103,9 @@ typedef enum /*< flags >*/
 /**
  * ThunarFileGetFunc:
  *
- * Callback type for loading #ThunarFile<!---->s asynchronously.
+ * Callback type for loading #ThunarFile<!---->s asynchronously. If you
+ * want to keep the #ThunarFile, you need to ref it, else it will be
+ * destroyed.
  **/
 typedef void (*ThunarFileGetFunc) (GFile      *location,
                                    ThunarFile *file,


More information about the Xfce4-commits mailing list