mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 14:58:05 +02:00
config: make NMConfig non-refcounted
It's a singleton that always exists. Callers shouldn't have to refcount it. Also, move its cleanup code from dispose() to finalize(), and remove some unnecessary checks in it.
This commit is contained in:
parent
53bd84feff
commit
4a7727d93a
2 changed files with 11 additions and 45 deletions
|
|
@ -180,7 +180,6 @@ NMConfig *
|
|||
nm_config_get (void)
|
||||
{
|
||||
g_assert (singleton);
|
||||
g_object_ref (singleton);
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
|
@ -284,51 +283,20 @@ nm_config_init (NMConfig *config)
|
|||
NM_CONFIG_GET_PRIVATE (config)->connectivity_interval = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
NMConfig *config = NM_CONFIG (object);
|
||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
if (priv->path) {
|
||||
g_free (priv->path);
|
||||
priv->path = NULL;
|
||||
}
|
||||
if (priv->plugins) {
|
||||
g_strfreev (priv->plugins);
|
||||
priv->plugins = NULL;
|
||||
}
|
||||
if (priv->dhcp_client) {
|
||||
g_free (priv->dhcp_client);
|
||||
priv->dhcp_client = NULL;
|
||||
}
|
||||
if (priv->dns_plugins) {
|
||||
g_strfreev (priv->dns_plugins);
|
||||
priv->dns_plugins = NULL;
|
||||
}
|
||||
if (priv->log_level) {
|
||||
g_free (priv->log_level);
|
||||
priv->log_level = NULL;
|
||||
}
|
||||
if (priv->log_domains) {
|
||||
g_free (priv->log_domains);
|
||||
priv->log_domains = NULL;
|
||||
}
|
||||
if (priv->connectivity_uri) {
|
||||
g_free (priv->connectivity_uri);
|
||||
priv->connectivity_uri = NULL;
|
||||
}
|
||||
if (priv->connectivity_response) {
|
||||
g_free (priv->connectivity_response);
|
||||
priv->connectivity_response = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nm_config_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *gobject)
|
||||
{
|
||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (gobject);
|
||||
|
||||
g_free (priv->path);
|
||||
g_strfreev (priv->plugins);
|
||||
g_free (priv->dhcp_client);
|
||||
g_strfreev (priv->dns_plugins);
|
||||
g_free (priv->log_level);
|
||||
g_free (priv->log_domains);
|
||||
g_free (priv->connectivity_uri);
|
||||
g_free (priv->connectivity_response);
|
||||
|
||||
singleton = NULL;
|
||||
G_OBJECT_CLASS (nm_config_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
|
@ -340,7 +308,6 @@ nm_config_class_init (NMConfigClass *config_class)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
|
||||
|
||||
g_type_class_add_private (config_class, sizeof (NMConfigPrivate));
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,6 @@ nm_connectivity_new (void)
|
|||
NULL);
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
update_connected (self, FALSE);
|
||||
g_object_unref (config);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue