mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-08 21:48:08 +02:00
lib: Remove hidden singleton instance
GObject _new constructors should always return a new pointer and not do
anything else than g_{object,initable}_new(). Drop the internal
up_client_object singleton instance.
This simplifies the code and makes the code robust with multiple threads.
Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
This commit is contained in:
parent
4e83fabac1
commit
29c5c85f6b
1 changed files with 1 additions and 9 deletions
|
|
@ -72,7 +72,6 @@ enum {
|
|||
};
|
||||
|
||||
static guint signals [UP_CLIENT_LAST_SIGNAL] = { 0 };
|
||||
static gpointer up_client_object = NULL;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init))
|
||||
|
|
@ -511,14 +510,7 @@ up_client_finalize (GObject *object)
|
|||
UpClient *
|
||||
up_client_new_full (GCancellable *cancellable, GError **error)
|
||||
{
|
||||
if (up_client_object != NULL) {
|
||||
g_object_ref (up_client_object);
|
||||
} else {
|
||||
up_client_object = g_initable_new (UP_TYPE_CLIENT, cancellable, error, NULL);
|
||||
if (up_client_object)
|
||||
g_object_add_weak_pointer (up_client_object, &up_client_object);
|
||||
}
|
||||
return UP_CLIENT (up_client_object);
|
||||
return g_initable_new (UP_TYPE_CLIENT, cancellable, error, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue