diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-05-18 10:12:25 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-05-18 14:59:12 +0200 |
commit | 29c5c85f6bf2a163c8713641dba634910ee3cf49 (patch) | |
tree | 6dd14531335a57c86293433c49031fb43f902907 /libupower-glib/up-client.c | |
parent | 4e83fabac13250fdc61ef5db817e82c32b7b301b (diff) | |
download | upower-29c5c85f6bf2a163c8713641dba634910ee3cf49.tar.gz |
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
Diffstat (limited to 'libupower-glib/up-client.c')
-rw-r--r-- | libupower-glib/up-client.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index adc0b9b..330c0ad 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -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); } /** |