[glib] GUnixSocketAddress: fix construct parameter issue
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GUnixSocketAddress: fix construct parameter issue
- Date: Tue, 23 Apr 2013 18:36:21 +0000 (UTC)
commit 9c243beea25f08b506eab9e1e877d6ffe2b20531
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Apr 23 13:38:33 2013 -0400
GUnixSocketAddress: fix construct parameter issue
GUnixSocketAddress has some very strange logic for interpreting its
construct paramters. This logic behaves differently in these two cases:
g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
"abstract", FALSE,
"address-type", ...,
NULL);
and
g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
"address-type", ...,
NULL);
even though the default value for "abstract" is already FALSE.
Change the way the code works so that it is not sensitive to people
merely setting a property to its default value.
https://bugzilla.gnome.org/show_bug.cgi?id=698686
gio/gunixsocketaddress.c | 23 ++++++-----------------
1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/gio/gunixsocketaddress.c b/gio/gunixsocketaddress.c
index 31615cf..84010e7 100644
--- a/gio/gunixsocketaddress.c
+++ b/gio/gunixsocketaddress.c
@@ -117,26 +117,15 @@ g_unix_socket_address_set_property (GObject *object,
break;
case PROP_ABSTRACT:
- /* If the caller already set PROP_ADDRESS_TYPE, don't let the
- * default value of PROP_ABSTRACT overwrite it.
- */
- if (address->priv->address_type != G_UNIX_SOCKET_ADDRESS_INVALID)
- return;
-
+ /* Only set it if it's not the default... */
if (g_value_get_boolean (value))
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED;
- else
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_PATH;
+ address->priv->address_type = G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED;
break;
case PROP_ADDRESS_TYPE:
- /* If the caller already set PROP_ABSTRACT, don't let the
- * default value of PROP_ADDRESS_TYPE overwrite it.
- */
- if (address->priv->address_type != G_UNIX_SOCKET_ADDRESS_INVALID)
- return;
-
- address->priv->address_type = g_value_get_enum (value);
+ /* Only set it if it's not the default... */
+ if (g_value_get_enum (value) != G_UNIX_SOCKET_ADDRESS_PATH)
+ address->priv->address_type = g_value_get_enum (value);
break;
default:
@@ -322,7 +311,7 @@ g_unix_socket_address_init (GUnixSocketAddress *address)
memset (address->priv->path, 0, sizeof (address->priv->path));
address->priv->path_len = -1;
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_INVALID;
+ address->priv->address_type = G_UNIX_SOCKET_ADDRESS_PATH;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]