After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772178 - Data is not saved after re-editing task
Data is not saved after re-editing task
Status: RESOLVED FIXED
Product: gnome-todo
Classification: Other
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME To Do maintainer(s)
GNOME To Do maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-09-29 12:29 UTC by Victor Toso
Modified: 2016-10-13 16:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
edit-pane: lower indentation with early return (4.15 KB, patch)
2016-10-02 21:50 UTC, Victor Toso
committed Details | Review
edit-pane: save task after editing (3.98 KB, patch)
2016-10-02 21:50 UTC, Victor Toso
none Details | Review
edit-pane: save loaded task on quit (1.40 KB, patch)
2016-10-02 21:50 UTC, Victor Toso
none Details | Review
edit-pane: check if binding is still valid (1.25 KB, patch)
2016-10-02 21:51 UTC, Victor Toso
none Details | Review
edit-pane: save task after editing (3.71 KB, patch)
2016-10-13 15:56 UTC, Victor Toso
committed Details | Review
edit-pane: save loaded task on quit (1.40 KB, patch)
2016-10-13 15:56 UTC, Victor Toso
committed Details | Review
edit-pane: check if binding is still valid (1.31 KB, patch)
2016-10-13 15:56 UTC, Victor Toso
committed Details | Review

Description Victor Toso 2016-09-29 12:29:10 UTC
This is on master branch.

I create a task, then I try to edit it either by setting date or description. The changes are not saved after I close gnome-todo (very frustrating)

The list is a local one.
Comment 1 Victor Toso 2016-09-29 13:27:35 UTC
Ha. To save what I have edited, I *must* close the edit pane. I realized it by code inspection ...

/**¬  
 * GtdEditPane::edit-finished:¬
 *¬
 * Emitted when the the user finishes editing the task, i.e. the pane is closed.¬
 */¬
signals[EDIT_FINISHED] = g_signal_new ("edit-finished",¬
Comment 2 Victor Toso 2016-09-29 13:31:04 UTC
I suggested that the Task should set the priv->should_save_task boolean whenever one of its properties changes (description, date, etc) and likely will be saved when switching to a new task.
Comment 3 Victor Toso 2016-10-02 21:50:27 UTC
Created attachment 336778 [details] [review]
edit-pane: lower indentation with early return

---
Not sure if I'm breaking the code style, if that's the case feel free to drop
it.
Comment 4 Victor Toso 2016-10-02 21:50:45 UTC
Created attachment 336779 [details] [review]
edit-pane: save task after editing

Before this change, the task is only saved if user closes the
edit-pane which makes very easy to lose data from changes.

We mark the should_save_task boolean as soon as any change happens and
we will save whenever a new task is loaded.
Comment 5 Victor Toso 2016-10-02 21:50:53 UTC
Created attachment 336780 [details] [review]
edit-pane: save loaded task on quit

If we have a loaded task with changes, we should ensure to save this
changes before quitting gnome-todo.
Comment 6 Victor Toso 2016-10-02 21:51:04 UTC
Created attachment 336781 [details] [review]
edit-pane: check if binding is still valid

It might not be valid on dispose:

 "The binding will automatically be removed when either the source or
  the target instances are finalized."
Comment 7 Georges Basile Stavracas Neto 2016-10-05 18:49:28 UTC
Review of attachment 336778 [details] [review]:

LGTM
Comment 8 Georges Basile Stavracas Neto 2016-10-05 18:53:12 UTC
Review of attachment 336779 [details] [review]:

Needs some minor improvements.

::: src/gtd-edit-pane.c
@@ +371,3 @@
       g_clear_pointer (&priv->priority_binding, g_binding_unbind);
+      g_signal_handler_disconnect (gtk_text_view_get_buffer (priv->notes_textview), priv->notes_changed);
+      g_signal_handler_disconnect (priv->priority_combo, priv->priority_changed);

I prefer to use g_signal_handlers_disconnect_by_func() and not add fields to the private section of the class.

@@ +399,3 @@
+      priv->notes_changed = g_signal_connect (buffer, "notify::text",
+                                              G_CALLBACK (gtd_edit_pane__task_changed_cb),
+                                              pane);

This breaks the coding style. One line per argument.

@@ +413,3 @@
+                                                 G_CALLBACK (gtd_edit_pane__task_changed_cb),
+                                                 pane);
+

Ditto.
Comment 9 Georges Basile Stavracas Neto 2016-10-05 18:53:54 UTC
Review of attachment 336780 [details] [review]:

Why not on finalize() ?
Comment 10 Georges Basile Stavracas Neto 2016-10-05 18:59:10 UTC
Review of attachment 336781 [details] [review]:

This is the wrong approach. I'd rather track down where the task is being finalized rather than using this kind of hack here.
Comment 11 Victor Toso 2016-10-13 15:12:03 UTC
Comment on attachment 336778 [details] [review]
edit-pane: lower indentation with early return

Attachment 336778 [details] pushed as 744b4b6 - edit-pane: lower indentation with early return
Comment 12 Victor Toso 2016-10-13 15:49:04 UTC
(In reply to Georges Basile Stavracas Neto from comment #9)
> Review of attachment 336780 [details] [review] [review]:
> 
> Why not on finalize() ?

Well, we are releasing/saving resources from the object so I thought these fits better the dispose method as per:

https://developer.gnome.org/gobject/stable/gobject-memory.html

Let me know if you want me to change that, or update the commit with that info.
Comment 13 Victor Toso 2016-10-13 15:53:07 UTC
(In reply to Georges Basile Stavracas Neto from comment #10)
> Review of attachment 336781 [details] [review] [review]:
> 
> This is the wrong approach. I'd rather track down where the task is being
> finalized rather than using this kind of hack here.

I don't follow why this is wrong. It isn't the task that has been finalized as we are on dispose method at this moment. The other objects that might be already released at this point making notes_binding and priority_binding invalid.
Comment 14 Victor Toso 2016-10-13 15:54:48 UTC
I'll re-submit the patch with minor fixes and the other two due the need to rebase them.
Comment 15 Victor Toso 2016-10-13 15:56:05 UTC
Created attachment 337616 [details] [review]
edit-pane: save task after editing

Before this change, the task is only saved if user closes the
edit-pane which makes very easy to lose data from changes.

We mark the should_save_task boolean as soon as any change happens and
we will save whenever a new task is loaded.
Comment 16 Victor Toso 2016-10-13 15:56:10 UTC
Created attachment 337617 [details] [review]
edit-pane: save loaded task on quit

If we have a loaded task with changes, we should ensure to save this
changes before quitting gnome-todo.
Comment 17 Victor Toso 2016-10-13 15:56:15 UTC
Created attachment 337618 [details] [review]
edit-pane: check if binding is still valid

It might not be valid on dispose:

 "The binding will automatically be removed when either the source or
  the target instances are finalized."
Comment 18 Georges Basile Stavracas Neto 2016-10-13 16:10:29 UTC
Review of attachment 337616 [details] [review]:

LGTM.
Comment 19 Georges Basile Stavracas Neto 2016-10-13 16:10:58 UTC
Review of attachment 337617 [details] [review]:

Ok, my fault. LGTM.
Comment 20 Georges Basile Stavracas Neto 2016-10-13 16:11:32 UTC
Review of attachment 337618 [details] [review]:

I didn't fall in love with this approach, but that's probably the best we can do.
Comment 21 Victor Toso 2016-10-13 16:35:03 UTC
Attachment 337616 [details] pushed as e201486 - edit-pane: save task after editing
Attachment 337617 [details] pushed as 9232197 - edit-pane: save loaded task on quit
Attachment 337618 [details] pushed as 44a6a47 - edit-pane: check if binding is still valid