[gvfs/wip/udisks2] udisks2: handle when g_dbus_interface_get_object() returns NULL
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/udisks2] udisks2: handle when g_dbus_interface_get_object() returns NULL
- Date: Fri, 7 Oct 2011 16:15:42 +0000 (UTC)
commit 51101993ea9c5cb7dabab4ae6cab8621abc8a038
Author: David Zeuthen <davidz redhat com>
Date: Fri Oct 7 12:15:01 2011 -0400
udisks2: handle when g_dbus_interface_get_object() returns NULL
Signed-off-by: David Zeuthen <davidz redhat com>
monitor/udisks2/gvfsudisks2mount.c | 17 +++++++++++++----
monitor/udisks2/gvfsudisks2volume.c | 19 +++++++++++++++----
monitor/udisks2/gvfsudisks2volumemonitor.c | 11 +++++++++--
3 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2mount.c b/monitor/udisks2/gvfsudisks2mount.c
index 1745134..58b341a 100644
--- a/monitor/udisks2/gvfsudisks2mount.c
+++ b/monitor/udisks2/gvfsudisks2mount.c
@@ -910,7 +910,6 @@ gvfs_udisks2_mount_unmount_with_operation (GMount *_mount,
GVfsUDisks2Mount *mount = GVFS_UDISKS2_MOUNT (_mount);
UnmountData *data;
UDisksBlock *block;
- UDisksObject *object;
/* first emit the ::mount-pre-unmount signal */
g_signal_emit_by_name (mount->monitor, "mount-pre-unmount", mount);
@@ -936,13 +935,23 @@ gvfs_udisks2_mount_unmount_with_operation (GMount *_mount,
block = gvfs_udisks2_volume_get_block (data->mount->volume);
if (block != NULL)
{
- object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (block)));
- data->filesystem = udisks_object_get_filesystem (object);
+ GDBusObject *object;
+ object = g_dbus_interface_get_object (G_DBUS_INTERFACE (block));
+ if (object == NULL)
+ {
+ g_simple_async_result_set_error (data->simple,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "No object for D-Bus interface");
+ g_simple_async_result_complete (data->simple);
+ unmount_data_free (data);
+ }
+ data->filesystem = udisks_object_get_filesystem (UDISKS_OBJECT (object));
if (data->filesystem == NULL)
{
UDisksBlock *cleartext_block;
- data->encrypted = udisks_object_get_encrypted (object);
+ data->encrypted = udisks_object_get_encrypted (UDISKS_OBJECT (object));
if (data->encrypted == NULL)
{
g_simple_async_result_set_error (data->simple,
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index a2a0934..82e2660 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -1002,7 +1002,7 @@ gvfs_udisks2_volume_mount (GVolume *_volume,
gpointer user_data)
{
GVfsUDisks2Volume *volume = GVFS_UDISKS2_VOLUME (_volume);
- UDisksObject *object;
+ GDBusObject *object;
UDisksBlock *block;
UDisksFilesystem *filesystem;
MountData *data;
@@ -1042,11 +1042,22 @@ gvfs_udisks2_volume_mount (GVolume *_volume,
else
block = volume->block;
- object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (block)));
- filesystem = udisks_object_peek_filesystem (object);
+ object = g_dbus_interface_get_object (G_DBUS_INTERFACE (block));
+ if (object == NULL)
+ {
+ g_simple_async_result_set_error (data->simple,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "No object for D-Bus interface");
+ g_simple_async_result_complete (data->simple);
+ mount_data_free (data);
+ goto out;
+ }
+
+ filesystem = udisks_object_peek_filesystem (UDISKS_OBJECT (object));
if (filesystem == NULL)
{
- data->encrypted_to_unlock = udisks_object_get_encrypted (object);
+ data->encrypted_to_unlock = udisks_object_get_encrypted (UDISKS_OBJECT (object));
if (data->encrypted_to_unlock != NULL)
{
do_unlock (data);
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index f6ccc2a..73b305f 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -694,8 +694,15 @@ should_include_drive (GVfsUDisks2VolumeMonitor *monitor,
static gint
udisks_drive_compare (UDisksDrive *a, UDisksDrive *b)
{
- return g_strcmp0 (g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (a))),
- g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (b))));
+ GDBusObject *oa = g_dbus_interface_get_object (G_DBUS_INTERFACE (a));
+ GDBusObject *ob = g_dbus_interface_get_object (G_DBUS_INTERFACE (b));
+ /* Either or both of oa, ob can be NULL for the case where a drive
+ * is removed but we still hold a reference to the drive interface
+ */
+ if (oa != NULL && ob != NULL)
+ return g_strcmp0 (g_dbus_object_get_object_path (oa), g_dbus_object_get_object_path (ob));
+ else
+ return (const gchar*) ob - (const gchar*) oa;
}
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]