[rygel-gst-0-10-plugins] Better cleanup of RygelMediaExportMusicItem



commit a60143e2ef8641b1eab7cd8fa0043a2e6e1bde62
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Jan 30 11:15:49 2013 +0100

    Better cleanup of RygelMediaExportMusicItem

 src/media-export/rygel-media-export-music-item.c |   48 +++++++---------------
 1 files changed, 15 insertions(+), 33 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-music-item.c b/src/media-export/rygel-media-export-music-item.c
index b7bad1f..4433db0 100644
--- a/src/media-export/rygel-media-export-music-item.c
+++ b/src/media-export/rygel-media-export-music-item.c
@@ -28,16 +28,6 @@ static void rygel_media_export_music_item_rygel_updatable_object_interface_init
 G_DEFINE_TYPE_WITH_CODE (RygelMediaExportMusicItem, rygel_media_export_music_item, RYGEL_TYPE_MUSIC_ITEM,
        G_IMPLEMENT_INTERFACE (RYGEL_TYPE_UPDATABLE_OBJECT, rygel_media_export_music_item_rygel_updatable_object_interface_init))
 
-typedef struct _RygelMediaExportMusicItemCommitData RygelMediaExportMusicItemCommitData;
-
-struct _RygelMediaExportMusicItemCommitData {
-  RygelMediaExportMusicItem *self;
-  GSimpleAsyncResult *async_result;
-  RygelMediaExportMediaCache *cache;
-  GError *error;
-};
-
-
 static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback_, gpointer user_data);
 
 /* TODO: Remove the construct function? */
@@ -63,45 +53,37 @@ static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *bas
   g_return_if_fail (self);
   g_return_if_fail (callback);
 
-  /* Create a data structure to hold our state
-   * during the async call.
-   */
-  RygelMediaExportMusicItemCommitData *data =
-    g_slice_new0 (RygelMediaExportMusicItemCommitData);
-  data->self = self;
-  g_object_ref (data->self);
-
   /* Setup the async result.
    */
-  data->async_result =
+  GSimpleAsyncResult *async_result =
     g_simple_async_result_new (G_OBJECT (self), callback, user_data,
       rygel_media_export_music_item_real_commit);
 
-  data->cache =
-    rygel_media_export_media_cache_get_default (&data->error);
-
   /* Do the work that could take a while.
    */
-  rygel_media_export_media_cache_save_item (data->cache,
-    RYGEL_MEDIA_ITEM (data->self), &data->error);
+  GError *error = NULL;
+  RygelMediaExportMediaCache *cache =
+    rygel_media_export_media_cache_get_default (&error);
+  if (!error) {
+    rygel_media_export_media_cache_save_item (cache,
+      RYGEL_MEDIA_ITEM (self), &error);
+  }
 
-  /* Set the error in the async result, if necessary.
+  /* Set any error in the async result, if necessary.
    */
-  if (data->error) {
-    g_simple_async_result_set_from_error (data->async_result, data->error);
-    g_error_free (data->error);
+  if (error) {
+    g_simple_async_result_set_from_error (async_result, error);
+    g_error_free (error);
   }
 
   /* Let the caller know that the async operation is finished,
    * and that its result is now available.
    */
-  g_simple_async_result_complete (data->async_result);
+  g_simple_async_result_complete (async_result);
 
   /* Free our data structure. */
-  g_object_unref (data->self);
-  g_object_unref (data->async_result);
-  g_object_unref (data->cache);
-  g_slice_free (RygelMediaExportMusicItemCommitData, data);
+  g_object_unref (async_result);
+  g_object_unref (cache);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]