[glib] Fix volumemonitor test case



commit b91f9274d9de1e9f0a1b407913ab893cfe1d5b25
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Aug 6 13:12:20 2010 -0400

    Fix volumemonitor test case
    
    Don't blindly g_object_unref() that which may be NULL.

 gio/tests/volumemonitor.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/volumemonitor.c b/gio/tests/volumemonitor.c
index 921e848..fe7d784 100644
--- a/gio/tests/volumemonitor.c
+++ b/gio/tests/volumemonitor.c
@@ -16,11 +16,13 @@ do_mount_tests (GDrive *drive, GVolume *volume, GMount *mount)
 
   v = g_mount_get_volume (mount);
   g_assert (v == volume);
-  g_object_unref (v);
+  if (v != NULL)
+    g_object_unref (v);
 
   d = g_mount_get_drive (mount);
   g_assert (d == drive);
-  g_object_unref (d);
+  if (d != NULL)
+    g_object_unref (d);
 
   uuid = g_mount_get_uuid (mount);
   if (uuid)
@@ -147,8 +149,11 @@ test_mounts (void)
       drive = g_mount_get_drive (mount);
       volume = g_mount_get_volume (mount);
       do_mount_tests (drive, volume, mount);
-      g_object_unref (drive);
-      g_object_unref (volume);
+
+      if (drive != NULL)
+        g_object_unref (drive);
+      if (volume != NULL)
+        g_object_unref (volume);
     }
 
   g_list_foreach (mounts, (GFunc)g_object_unref,  NULL);



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