up-polkit: remove global variable and remove g_object_add_weak_pointer()

Since UpPolkit is only created in the daemon, so the global variable and
g_object_add_weak_pointer() can be removed.
This commit is contained in:
Kate Hsuan 2024-09-02 14:03:56 +08:00
parent 88031e563f
commit 7db90b28d8

View file

@ -45,7 +45,6 @@ struct UpPolkitPrivate
G_DEFINE_TYPE_WITH_CODE (UpPolkit, up_polkit, G_TYPE_OBJECT,
G_ADD_PRIVATE (UpPolkit))
static gpointer up_polkit_object = NULL;
#ifdef HAVE_POLKIT
/**
@ -190,12 +189,6 @@ up_polkit_init (UpPolkit *polkit)
UpPolkit *
up_polkit_new (void)
{
if (up_polkit_object != NULL) {
g_object_ref (up_polkit_object);
} else {
up_polkit_object = g_object_new (UP_TYPE_POLKIT, NULL);
g_object_add_weak_pointer (up_polkit_object, &up_polkit_object);
}
return UP_POLKIT (up_polkit_object);
return UP_POLKIT (g_object_new (UP_TYPE_POLKIT, NULL));
}