policy: remove initialized guard from nm_policy_new()
authorThomas Haller <thaller@redhat.com>
Tue, 29 Mar 2016 08:39:47 +0000 (10:39 +0200)
committerThomas Haller <thaller@redhat.com>
Tue, 29 Mar 2016 10:18:15 +0000 (12:18 +0200)
If we want to ensure that we create only one single instance of
NMPolicy, just don't create multiple instances. The nm_policy_new()
method should not be restriced and behave like other *new() functions
and create a new object as requested.

src/nm-policy.c

index e855c42..f16729a 100644 (file)
@@ -1898,19 +1898,13 @@ constructed (GObject *object)
 NMPolicy *
 nm_policy_new (NMManager *manager, NMSettings *settings)
 {
-       NMPolicy *policy;
-       static gboolean initialized = FALSE;
-
        g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
        g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL);
-       g_return_val_if_fail (initialized == FALSE, NULL);
-
-       policy = g_object_new (NM_TYPE_POLICY,
-                              NM_POLICY_MANAGER, manager,
-                              NM_POLICY_SETTINGS, settings,
-                              NULL);
-       initialized = TRUE;
-       return policy;
+
+       return g_object_new (NM_TYPE_POLICY,
+                            NM_POLICY_MANAGER, manager,
+                            NM_POLICY_SETTINGS, settings,
+                            NULL);
 }
 
 static void