It is not useful to assert that task_data != NULL after
using it to build the D-Bus key.
Move the assertion to before it is first used and get
rid of this inconsistency.
As per doumentation: "It is a programming error to create an identical proxy
while asynchronously creating one. Not cancelling this operation will result in
an assertion failure when calling cc_object_storage_create_dbus_proxy_finish()."
In order to fullfill the second part we need to check for errors (including
cancellation ones) before we generate an assertion failure.
Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/158
CcObjectStorage is a cache for GObjects. It is meant to
store objects that are too expensive to be often created,
such as NMClient, GoaClient or D-Bus proxies.
CcObjectStorage has a very strict usage pattern. It is a
programming error to add an object that is already stored,
and so it is to retrieve an object that was not stored.
Stored objects are meant to be kept alive during the whole
lifetime of GNOME Settings, and CcObjectStorage takes a
reference on every stored object to achieve that.
If objects are destroyed while they are cached, it means
we have a reference mismanagement somewhere. In this sense,
CcObjectStorage will act Sam Sheepdog taking care of sneaky
wolves trying to steal their sheep-references.
Next patches will make various panels and objects around
GNOME Settings adopt this new API, and make sure they always
disconnect when destroyed.