datetime: Don't unconditionally use self in async cbs

If the page is closed before the async call finishes, the page is
unreffed and gets disposed, resulting in a crash when the finish handler
is called, as it may try to access pointers of self that got set to NULL
in the disposer.

To prevent this, use the source object directly, which is guaranteed to
be alive during the call and callback. If self gets disposed during the
async call, we'll get a warning that the cancellable was cancelled
instead of a crash.

Fixes #3045
This commit is contained in:
Matthijs Velsink 2024-05-05 18:21:08 +02:00 committed by Felipe Borges
parent 82986f3e92
commit 1c0815490a

View file

@ -256,7 +256,7 @@ set_time_cb (GObject *source,
CcDateTimePage *self = user_data;
g_autoptr(GError) error = NULL;
if (!timedate1_call_set_time_finish (self->dtm,
if (!timedate1_call_set_time_finish (TIMEDATE1 (source),
res,
&error))
{
@ -277,7 +277,7 @@ set_timezone_cb (GObject *source,
CcDateTimePage *self = user_data;
g_autoptr(GError) error = NULL;
if (!timedate1_call_set_timezone_finish (self->dtm,
if (!timedate1_call_set_timezone_finish (TIMEDATE1 (source),
res,
&error))
{
@ -294,7 +294,7 @@ set_using_ntp_cb (GObject *source,
CcDateTimePage *self = user_data;
g_autoptr(GError) error = NULL;
if (!timedate1_call_set_ntp_finish (self->dtm,
if (!timedate1_call_set_ntp_finish (TIMEDATE1 (source),
res,
&error))
{