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 768175 - bookmark-list: port to GTask
bookmark-list: port to GTask
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-29 11:03 UTC by Ernestas Kulik
Modified: 2016-08-13 08:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bookmark-list: port to GTask (4.46 KB, patch)
2016-06-29 11:03 UTC, Ernestas Kulik
none Details | Review
bookmark-list: port to GTask (4.50 KB, patch)
2016-06-29 12:26 UTC, Ernestas Kulik
none Details | Review
bookmark-list: port to GTask (5.52 KB, patch)
2016-06-29 13:24 UTC, Ernestas Kulik
none Details | Review
bookmark-list: port to GTask (5.49 KB, patch)
2016-06-29 13:38 UTC, Ernestas Kulik
none Details | Review
bookmark-list: port to GTask (5.51 KB, patch)
2016-07-02 09:56 UTC, Ernestas Kulik
none Details | Review
bookmark-list: port to GTask (5.51 KB, patch)
2016-07-07 14:01 UTC, Ernestas Kulik
committed Details | Review
bookmark-list: null-initialize error pointer (883 bytes, patch)
2016-08-13 06:54 UTC, Ernestas Kulik
committed Details | Review

Description Ernestas Kulik 2016-06-29 11:03:05 UTC
As the quest to eliminate deprecated code continues, I’ve decided to tackle bookmark-list.
Comment 1 Ernestas Kulik 2016-06-29 11:03:10 UTC
Created attachment 330556 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 2 Razvan Chitu 2016-06-29 11:58:14 UTC
Review of attachment 330556 [details] [review]:

Nice job, I think this is the last nail in the coffin of non-GTask multithreading in Nautilus! Still a few little things that I think should be adjusted though.

::: src/nautilus-bookmark-list.c
@@ +335,3 @@
+
+	if (error != NULL) {
+		g_warning ("Unable to get contents of the bookmarks file: %s",

there's a similar warning in load_io_thread as well so you might want to remove one of them. also, I think error will never be != NULL, because g_task_return_error is not used and the task cannot be cancelled

@@ +344,1 @@
 	if (contents == NULL) {

can contents be NULL if error is also NULL?

@@ +397,2 @@
 		}
 		g_error_free (error);

you should use g_task_return_error here

@@ +454,3 @@
 	g_object_unref (parent);
 
+	contents = g_task_propagate_pointer (task, &error);

use task_data instead of returning and propagating a pointer. also, I'm not sure error will ever be != NULL, because the task cannot be cancelled and there is no other operation that can cause errors before the thread func is called.

@@ +521,2 @@
 	contents = g_string_free (bookmark_string, FALSE);
+	g_task_return_pointer (task, contents, g_free);

looking at the above code, "contents" should rather be task_data, not the return value of the task
Comment 3 Ernestas Kulik 2016-06-29 12:26:16 UTC
Created attachment 330569 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 4 Ernestas Kulik 2016-06-29 13:24:43 UTC
Created attachment 330583 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 5 Ernestas Kulik 2016-06-29 13:38:06 UTC
Created attachment 330587 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 6 Carlos Soriano 2016-06-30 07:50:53 UTC
Review of attachment 330587 [details] [review]:

The patch looks good to me except this small comment. Razvan, can you double check the patch too and mark as accept_commit_now if you agree (after the small comment I did fixed)?

Thanks Ernestas! GTask is kinda hard the first time :/

::: src/nautilus-bookmark-list.c
@@ +427,3 @@
+	}
+
+		g_warning ("Unable to replace contents of the bookmarks file: %s",

The docs say "if an error has occurred, this function will return FALSE and set error appropriately if present."
That means returning FALSE and not having error set is fine (I'm not aware of the details though).

So this comment can be removed, or at least reworded to something like:
"g_file_replace_contents can be unsuccessful and not set an error."
Comment 7 Ernestas Kulik 2016-06-30 08:11:07 UTC
(In reply to Carlos Soriano from comment #6)
> ::: src/nautilus-bookmark-list.c
> @@ +427,3 @@
> +	}
> +
> +		g_warning ("Unable to replace contents of the bookmarks file: %s",

Did you perhaps mean this?

+	// g_file_replace_contents() returned FALSE mysteriously.
+	if (!success) {
+		g_warning ("Unable to replace contents of the bookmarks file.");
+	}
Comment 8 Carlos Soriano 2016-06-30 08:47:28 UTC
I think bugzilla is tricking us :( click on the review link, you will see exactly the line I was reviewing (which is the one you point to)
Comment 9 Ernestas Kulik 2016-07-02 09:56:08 UTC
Created attachment 330769 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 10 Razvan Chitu 2016-07-07 13:53:38 UTC
Review of attachment 330769 [details] [review]:

besides that comment, the patch looks good to me!

::: src/nautilus-bookmark-list.c
@@ +427,3 @@
+	}
+
+	// g_file_replace_contents() returned FALSE, but did not set an error.

Use /* ... */ for comments
Comment 11 Ernestas Kulik 2016-07-07 14:01:31 UTC
Created attachment 331002 [details] [review]
bookmark-list: port to GTask

GSimpleAsyncResult utilities have been deprecated since GLib version
2.46 and using GTask is recommended. This commit replaces the
deprecated code.
Comment 12 Ernestas Kulik 2016-07-07 14:03:35 UTC
Attachment 331002 [details] pushed as 54b6341 - bookmark-list: port to GTask
Comment 13 Razvan Chitu 2016-08-13 06:47:38 UTC
Review of attachment 331002 [details] [review]:

Congrats, you broke Nautilus for the first time! :)

::: src/nautilus-bookmark-list.c
@@ +415,3 @@
 {
+	NautilusBookmarkList *self = NAUTILUS_BOOKMARK_LIST (source_object);
+	GError *error;

Initialize this to NULL.
Comment 14 Razvan Chitu 2016-08-13 06:47:41 UTC
Review of attachment 331002 [details] [review]:

Congrats, you broke Nautilus for the first time! :)

::: src/nautilus-bookmark-list.c
@@ +415,3 @@
 {
+	NautilusBookmarkList *self = NAUTILUS_BOOKMARK_LIST (source_object);
+	GError *error;

Initialize this to NULL.
Comment 15 Ernestas Kulik 2016-08-13 06:54:03 UTC
Created attachment 333204 [details] [review]
bookmark-list: null-initialize error pointer

A GError pointer was not being null-initialized, which can result in
crashes. This commit fixes that.
Comment 16 Ernestas Kulik 2016-08-13 06:57:09 UTC
(In reply to Razvan Chitu from comment #14)
> Congrats, you broke Nautilus for the first time! :)

And here’s to many more. *clink* :)
Comment 17 Carlos Soriano 2016-08-13 08:25:20 UTC
Review of attachment 333204 [details] [review]:

LGTM thanks!
Comment 18 Ernestas Kulik 2016-08-13 08:27:18 UTC
Attachment 333204 [details] pushed as d316950 - bookmark-list: null-initialize error pointer