[gnome-calendar/858-event-deletion-aborts-unfinished-previous-delete-attempt] gcal-window: Event deletion aborts unfinished previous delete attempt



commit 1fea08ab7226e1ee5589b6a91ff675afd1084233
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 5 18:23:28 2022 +0200

    gcal-window: Event deletion aborts unfinished previous delete attempt
    
    Cannot use g_clear_pointer() here, because it unsets the pointer first and
    only then calls the free function, which means the test on self->delete_event_toast
    NULL-ness would be satisfied in the on_toast_dismissed_cb(), thus the previous
    event delete attempt would be "cancelled" internally.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/858

 src/gui/gcal-window.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c
index 96afef5a..2976746a 100644
--- a/src/gui/gcal-window.c
+++ b/src/gui/gcal-window.c
@@ -694,7 +694,13 @@ on_event_editor_dialog_remove_event_cb (GcalEventEditorDialog *edit_dialog,
   GCAL_ENTRY;
 
   has_deleted_event = self->delete_event_toast != NULL;
-  g_clear_pointer (&self->delete_event_toast, adw_toast_dismiss);
+  /* Cannot use g_clear_pointer() here, because it unsets the pointer first and
+     only then calls the free function, which means the test on self->delete_event_toast
+     NULL-ness would be satisfied in the on_toast_dismissed_cb(), thus the previous
+     event delete attempt would be "cancelled" internally. */
+  if (self->delete_event_toast)
+    adw_toast_dismiss (self->delete_event_toast);
+  self->delete_event_toast = NULL;
 
   toast = adw_toast_new (has_deleted_event ? _("Another event deleted") : _("Event deleted"));
   adw_toast_set_timeout (toast, 5);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]