mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 17:30:09 +01:00
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 toc6529a9d74, this change was not possible because constructed() will call back into nm_platform_*() functions, without having the singleton instance setup. (cherry picked from commitdc9b25f161)
This commit is contained in:
parent
b3cbb768a3
commit
2cbcb6df51
2 changed files with 9 additions and 9 deletions
|
|
@ -4465,9 +4465,10 @@ nm_linux_platform_init (NMLinuxPlatform *platform)
|
|||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
setup (NMPlatform *platform)
|
||||
static void
|
||||
constructed (GObject *_object)
|
||||
{
|
||||
NMPlatform *platform = NM_PLATFORM (_object);
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
const char *udev_subsys[] = { "net", NULL };
|
||||
GUdevEnumerator *enumerator;
|
||||
|
|
@ -4564,7 +4565,7 @@ setup (NMPlatform *platform)
|
|||
|
||||
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
|
||||
|
|
@ -4599,10 +4600,9 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
g_type_class_add_private (klass, sizeof (NMLinuxPlatformPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = nm_linux_platform_finalize;
|
||||
|
||||
platform_class->setup = setup;
|
||||
|
||||
platform_class->sysctl_set = sysctl_set;
|
||||
platform_class->sysctl_get = sysctl_get;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ static NMPlatform *singleton_instance = NULL;
|
|||
void
|
||||
nm_platform_setup (GType type)
|
||||
{
|
||||
gboolean status;
|
||||
NMPlatformClass *klass;
|
||||
|
||||
g_assert (singleton_instance == NULL);
|
||||
|
|
@ -109,10 +108,11 @@ nm_platform_setup (GType type)
|
|||
g_assert (NM_IS_PLATFORM (singleton_instance));
|
||||
|
||||
klass = NM_PLATFORM_GET_CLASS (singleton_instance);
|
||||
g_assert (klass->setup);
|
||||
|
||||
status = klass->setup (singleton_instance);
|
||||
g_assert (status);
|
||||
if (klass->setup) {
|
||||
if (!klass->setup (singleton_instance))
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue