summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-11-28 11:18:54 +0100
committerJiří Klimeš <jklimes@redhat.com>2013-11-28 11:18:54 +0100
commit0d4a5f0328f8c92093dc2d54f8ee8ca3f6da42ed (patch)
tree2f867ba0155a6770573cdf8ceeff7b516107a31e
parente2ecf5b808c565cd618486f8fa097a9c79f97528 (diff)
downloadNetworkManager-0d4a5f0328f8c92093dc2d54f8ee8ca3f6da42ed.tar.gz
Revert "libnm-util: refactor NMSetting construction, assert of setting name"
This reverts commit f43586fc179b3e7ca82be110390c04336b5da37b. This broke stuff as "name" was set on various places after construction. So we revert the commit for now, and will rework it.
-rw-r--r--libnm-util/nm-setting.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c
index 6b5753afb2..b3db363b77 100644
--- a/libnm-util/nm-setting.c
+++ b/libnm-util/nm-setting.c
@@ -1165,6 +1165,30 @@ nm_setting_init (NMSetting *setting)
{
}
+static GObject*
+constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ NMSettingPrivate *priv;
+
+ object = G_OBJECT_CLASS (nm_setting_parent_class)->constructor (type,
+ n_construct_params,
+ construct_params);
+ if (!object)
+ return NULL;
+
+ priv = NM_SETTING_GET_PRIVATE (object);
+ if (!priv->name) {
+ g_warning ("Setting name is not set.");
+ g_object_unref (object);
+ object = NULL;
+ }
+
+ return object;
+}
+
static void
finalize (GObject *object)
{
@@ -1183,9 +1207,8 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_NAME:
- /* construct only */
+ g_free (priv->name);
priv->name = g_value_dup_string (value);
- g_assert (priv->name && *priv->name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1217,6 +1240,7 @@ nm_setting_class_init (NMSettingClass *setting_class)
g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
/* virtual methods */
+ object_class->constructor = constructor;
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
@@ -1245,6 +1269,6 @@ nm_setting_class_init (NMSettingClass *setting_class)
"has been created. Each setting class has a name, and "
"all objects of that class share the same name.",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE));
}