[gnome-photos/wip/rishi/collection: 12/39] source: Prevent the ID and name from getting overwritten
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 12/39] source: Prevent the ID and name from getting overwritten
- Date: Wed, 24 Jan 2018 20:03:13 +0000 (UTC)
commit b8e3223d0868aae2ec3a681796f5b4cefbc13a3c
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Jan 11 19:04:54 2018 +0100
source: Prevent the ID and name from getting overwritten
The "id" and "name" properties of a Source created from a GoaObject are
set based on attributes of the GoaObject, and are not separately routed
through GObject's property machinery. Since they are marked as
construct properties, GObject will set them to their default values,
which is NULL in both cases, regardless of whether they were already
set outside of the property machinery.
This hasn't been a problem so far because GObject sorts the construct
properties alphabetically before setting them, and "id" and "name"
precede "object". This will break when a "mount" property, analogous to
"object", for GMount-backed sources in a subsequent commit.
https://bugzilla.gnome.org/show_bug.cgi?id=751212
src/photos-source.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-source.c b/src/photos-source.c
index 24e0706c..f9e60eb6 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -175,12 +175,30 @@ photos_source_set_property (GObject *object, guint prop_id, const GValue *value,
break;
case PROP_ID:
- self->id = g_value_dup_string (value);
- break;
+ {
+ const gchar *id;
+
+ id = g_value_get_string (value);
+ g_return_if_fail (self->id == NULL || id == NULL);
+
+ if (self->id == NULL && id != NULL)
+ self->id = g_strdup (id);
+
+ break;
+ }
case PROP_NAME:
- self->name = g_value_dup_string (value);
- break;
+ {
+ const gchar *name;
+
+ name = g_value_get_string (value);
+ g_return_if_fail (self->name == NULL || name == NULL);
+
+ if (self->name == NULL && name != NULL)
+ self->name = g_strdup (name);
+
+ break;
+ }
case PROP_OBJECT:
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]