mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 11:40:08 +01:00
core: declare nm_sleep_monitor_get() using NM_DEFINE_SINGLETON_GETTER()
Also no longer increment the reference count in the getter and properly disconnect the signals in NMManager:dispose(). Also use the defines for the signal names instead of plain strings.
This commit is contained in:
parent
822cb293ef
commit
a8ebd1aa1a
3 changed files with 10 additions and 26 deletions
|
|
@ -4852,10 +4852,10 @@ nm_manager_init (NMManager *manager)
|
|||
nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy");
|
||||
|
||||
/* sleep/wake handling */
|
||||
priv->sleep_monitor = nm_sleep_monitor_get ();
|
||||
g_signal_connect (priv->sleep_monitor, "sleeping",
|
||||
priv->sleep_monitor = g_object_ref (nm_sleep_monitor_get ());
|
||||
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING,
|
||||
G_CALLBACK (sleeping_cb), manager);
|
||||
g_signal_connect (priv->sleep_monitor, "resuming",
|
||||
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_RESUMING,
|
||||
G_CALLBACK (resuming_cb), manager);
|
||||
|
||||
/* Listen for authorization changes */
|
||||
|
|
@ -5065,7 +5065,11 @@ dispose (GObject *object)
|
|||
}
|
||||
|
||||
g_clear_object (&priv->aipd_proxy);
|
||||
g_clear_object (&priv->sleep_monitor);
|
||||
if (priv->sleep_monitor) {
|
||||
g_signal_handlers_disconnect_by_func (priv->sleep_monitor, sleeping_cb, manager);
|
||||
g_signal_handlers_disconnect_by_func (priv->sleep_monitor, resuming_cb, manager);
|
||||
g_clear_object (&priv->sleep_monitor);
|
||||
}
|
||||
|
||||
if (priv->fw_monitor) {
|
||||
g_signal_handlers_disconnect_by_func (priv->fw_monitor, firmware_dir_changed, manager);
|
||||
|
|
|
|||
|
|
@ -243,16 +243,6 @@ nm_sleep_monitor_class_init (NMSleepMonitorClass *klass)
|
|||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
NMSleepMonitor *
|
||||
nm_sleep_monitor_get (void)
|
||||
{
|
||||
static NMSleepMonitor *singleton = NULL;
|
||||
|
||||
if (singleton)
|
||||
return g_object_ref (singleton);
|
||||
|
||||
singleton = NM_SLEEP_MONITOR (g_object_new (NM_TYPE_SLEEP_MONITOR, NULL));
|
||||
return singleton;
|
||||
}
|
||||
NM_DEFINE_SINGLETON_GETTER (NMSleepMonitor, nm_sleep_monitor_get, NM_TYPE_SLEEP_MONITOR);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -133,16 +133,6 @@ nm_sleep_monitor_class_init (NMSleepMonitorClass *klass)
|
|||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
NMSleepMonitor *
|
||||
nm_sleep_monitor_get (void)
|
||||
{
|
||||
static NMSleepMonitor *singleton = NULL;
|
||||
|
||||
if (singleton)
|
||||
return g_object_ref (singleton);
|
||||
|
||||
singleton = NM_SLEEP_MONITOR (g_object_new (NM_TYPE_SLEEP_MONITOR, NULL));
|
||||
return singleton;
|
||||
}
|
||||
NM_DEFINE_SINGLETON_GETTER (NMSleepMonitor, nm_sleep_monitor_get, NM_TYPE_SLEEP_MONITOR);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue