[gnome-todo/feature/unref-fixes: 1/3] edit-pane: Don't unconditionally ref due date




commit 5990e8c081a9ca55440d096c8e5517ce6584f6c8
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Fri Oct 8 19:04:37 2021 +0200

    edit-pane: Don't unconditionally ref due date
    
    `gtd_task_get_due_date()` can return a NULL-pointer, so we shouldn't
    just try to call `g_date_time_ref()` on it. Even if it doesn't return
    NULL, it's already `(transfer full)`, so we shouldn't be doing an extra
    refcount increase in the first place.
    
    Fixes a CRITICAL log message when setting a due date.

 src/core/gtd-task.c     | 2 +-
 src/gui/gtd-edit-pane.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/core/gtd-task.c b/src/core/gtd-task.c
index 6430060a..7c97afe7 100644
--- a/src/core/gtd-task.c
+++ b/src/core/gtd-task.c
@@ -658,7 +658,7 @@ gtd_task_set_description (GtdTask     *task,
  * The value is referenced for thread safety. Returns %NULL if
  * no date is set.
  *
- * Returns: (transfer full): the internal #GDateTime referenced
+ * Returns: (transfer full) (nullable): the internal #GDateTime referenced
  * for thread safety, or %NULL. Unreference it after use.
  */
 GDateTime*
diff --git a/src/gui/gtd-edit-pane.c b/src/gui/gtd-edit-pane.c
index 9f9dabc5..d8abd6e2 100644
--- a/src/gui/gtd-edit-pane.c
+++ b/src/gui/gtd-edit-pane.c
@@ -78,7 +78,7 @@ update_date_widgets (GtdEditPane *self)
 
   g_return_if_fail (GTD_IS_EDIT_PANE (self));
 
-  dt = self->task ? g_date_time_ref (gtd_task_get_due_date (self->task)) : NULL;
+  dt = self->task ? gtd_task_get_due_date (self->task) : NULL;
   text = dt ? g_date_time_format (dt, "%x") : NULL;
 
   g_signal_handlers_block_by_func (self->calendar, on_date_selected_cb, self);


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