[gnome-color-manager] trivial: do not crash when deleting devices that are not saved
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: do not crash when deleting devices that are not saved
- Date: Wed, 24 Mar 2010 12:40:01 +0000 (UTC)
commit f9679dec8029e99b7c16fa734c98ce4d1c858714
Author: Richard Hughes <richard hughsie com>
Date: Wed Mar 24 11:33:12 2010 +0000
trivial: do not crash when deleting devices that are not saved
src/gcm-client.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 47036d9..dfec191 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -987,20 +987,18 @@ gboolean
gcm_client_delete_device (GcmClient *client, GcmDevice *device, GError **error)
{
gboolean ret = FALSE;
- gchar *id = NULL;
+ const gchar *id;
gchar *data = NULL;
gchar *filename = NULL;
GKeyFile *keyfile = NULL;
+ gboolean saved;
gboolean connected;
g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
- /* check removable */
- g_object_get (device,
- "connected", &connected,
- "id", &id,
- NULL);
+ /* check device is not connected */
+ connected = gcm_device_get_connected (device);
if (connected) {
g_set_error_literal (error, 1, 0, "device is still connected");
goto out;
@@ -1013,6 +1011,12 @@ gcm_client_delete_device (GcmClient *client, GcmDevice *device, GError **error)
goto out;
}
+ /* check device is saved */
+ id = gcm_device_get_id (device);
+ saved = gcm_device_get_saved (device);
+ if (!saved)
+ goto not_saved;
+
/* get the config file */
filename = gcm_utils_get_default_config_location ();
egg_debug ("removing %s from %s", id, filename);
@@ -1045,11 +1049,11 @@ gcm_client_delete_device (GcmClient *client, GcmDevice *device, GError **error)
"saved", FALSE,
NULL);
+not_saved:
/* emit a signal */
egg_debug ("emit removed: %s", id);
g_signal_emit (client, signals[SIGNAL_REMOVED], 0, device);
out:
- g_free (id);
g_free (data);
g_free (filename);
if (keyfile != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]