power: Fix crash when power proxy becomes ready after finalize

While the code was using the pattern to cancel the operation, it was
still resolving the user_data pointer even in the case the operation has
been cancelled.

Fix this by simply moving the initialization.

Fixes: #1260
This commit is contained in:
Benjamin Berg 2021-02-16 15:42:27 +01:00
parent 84532449f4
commit 58c4a39af1

View file

@ -136,8 +136,6 @@ got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
CcBrightnessScale *self; CcBrightnessScale *self;
GDBusProxy *proxy; GDBusProxy *proxy;
self = CC_BRIGHTNESS_SCALE (user_data);
proxy = cc_object_storage_create_dbus_proxy_finish (res, &error); proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
if (proxy == NULL) if (proxy == NULL)
{ {
@ -146,6 +144,7 @@ got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
return; return;
} }
self = CC_BRIGHTNESS_SCALE (user_data);
self->proxy = proxy; self->proxy = proxy;
g_signal_connect_object (proxy, "g-properties-changed", g_signal_connect_object (proxy, "g-properties-changed",