platform: initialize NMLinuxPlatform in constructed() method
setup() can be used to initialize a NMPlatform instance that is
registered as singleton via nm_platform_setup(). It should not
be used to initialize the object.
Prior to c6529a9d74
, this change was
not possible because constructed() will call back into nm_platform_*()
functions, without having the singleton instance setup.
This commit is contained in:
@@ -4476,9 +4476,10 @@ nm_linux_platform_init (NMLinuxPlatform *platform)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
setup (NMPlatform *platform)
|
constructed (GObject *_object)
|
||||||
{
|
{
|
||||||
|
NMPlatform *platform = NM_PLATFORM (_object);
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
const char *udev_subsys[] = { "net", NULL };
|
const char *udev_subsys[] = { "net", NULL };
|
||||||
GUdevEnumerator *enumerator;
|
GUdevEnumerator *enumerator;
|
||||||
@@ -4575,7 +4576,7 @@ setup (NMPlatform *platform)
|
|||||||
|
|
||||||
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
||||||
|
|
||||||
return TRUE;
|
G_OBJECT_CLASS (nm_linux_platform_parent_class)->constructed (_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4610,10 +4611,9 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||||||
g_type_class_add_private (klass, sizeof (NMLinuxPlatformPrivate));
|
g_type_class_add_private (klass, sizeof (NMLinuxPlatformPrivate));
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
|
object_class->constructed = constructed;
|
||||||
object_class->finalize = nm_linux_platform_finalize;
|
object_class->finalize = nm_linux_platform_finalize;
|
||||||
|
|
||||||
platform_class->setup = setup;
|
|
||||||
|
|
||||||
platform_class->sysctl_set = sysctl_set;
|
platform_class->sysctl_set = sysctl_set;
|
||||||
platform_class->sysctl_get = sysctl_get;
|
platform_class->sysctl_get = sysctl_get;
|
||||||
|
|
||||||
|
@@ -100,7 +100,6 @@ static NMPlatform *singleton_instance = NULL;
|
|||||||
void
|
void
|
||||||
nm_platform_setup (GType type)
|
nm_platform_setup (GType type)
|
||||||
{
|
{
|
||||||
gboolean status;
|
|
||||||
NMPlatformClass *klass;
|
NMPlatformClass *klass;
|
||||||
|
|
||||||
g_assert (singleton_instance == NULL);
|
g_assert (singleton_instance == NULL);
|
||||||
@@ -109,10 +108,11 @@ nm_platform_setup (GType type)
|
|||||||
g_assert (NM_IS_PLATFORM (singleton_instance));
|
g_assert (NM_IS_PLATFORM (singleton_instance));
|
||||||
|
|
||||||
klass = NM_PLATFORM_GET_CLASS (singleton_instance);
|
klass = NM_PLATFORM_GET_CLASS (singleton_instance);
|
||||||
g_assert (klass->setup);
|
|
||||||
|
|
||||||
status = klass->setup (singleton_instance);
|
if (klass->setup) {
|
||||||
g_assert (status);
|
if (!klass->setup (singleton_instance))
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user