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 708736 - Add support for using GBytes with GcrParser
Add support for using GBytes with GcrParser
Status: RESOLVED FIXED
Product: gcr
Classification: Core
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME keyring maintainer(s)
GNOME keyring maintainer(s)
Depends on:
Blocks: 705225
 
 
Reported: 2013-09-25 11:19 UTC by Stef Walter
Modified: 2019-02-22 11:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gcr: Allow using GBytes with GcrParser (28.95 KB, patch)
2013-09-25 11:19 UTC, Stef Walter
reviewed Details | Review
gcr: Allow using GBytes with GcrParser (29.25 KB, patch)
2013-09-30 15:03 UTC, Stef Walter
committed Details | Review

Description Stef Walter 2013-09-25 11:19:17 UTC
When we migrated to using GBytes in the Gcr library, we didn't add support for using GBytes with GcrParser. A TODO is present. This is a problem because GcrParser and GcrParsed assume that they can hold a reference to the input data.
Comment 1 Stef Walter 2013-09-25 11:19:42 UTC
Created attachment 255675 [details] [review]
gcr: Allow using GBytes with GcrParser

This also solves a corner case where GcrParser would keep around a
pointer to the data passed into gcr_parser_parse_data(), even after
that data had been freed.

gcr_parser_parse_data() now copies the data passed in, where as
the new gcr_parser_parse_bytes() simply keeps a reference to the
GBytes.
Comment 2 Hashem Nasarat 2013-09-30 13:31:43 UTC
Review of attachment 255675 [details] [review]:

Looks mostly good. How can I run the tests though?

::: gcr/gcr-parser.c
@@ +2395,3 @@
 
+	if (g_bytes_get_size (data) > 0) {
+		args.data = g_bytes_ref (data);

Should there be a corresponding g_bytes_unref in the finalize function?

::: gcr/tests/test-parser.c
@@ +266,3 @@
+	fis = g_file_read (file, NULL, &error);
+	g_assert_no_error (error);
+

Do you want to connect to the "parsed" signal here like in test_parsed_bytes?
Comment 3 Hashem Nasarat 2013-09-30 13:31:43 UTC
Review of attachment 255675 [details] [review]:

Looks mostly good. How can I run the tests though?

::: gcr/gcr-parser.c
@@ +2395,3 @@
 
+	if (g_bytes_get_size (data) > 0) {
+		args.data = g_bytes_ref (data);

Should there be a corresponding g_bytes_unref in the finalize function?

::: gcr/tests/test-parser.c
@@ +266,3 @@
+	fis = g_file_read (file, NULL, &error);
+	g_assert_no_error (error);
+

Do you want to connect to the "parsed" signal here like in test_parsed_bytes?
Comment 4 Stef Walter 2013-09-30 15:00:08 UTC
(In reply to comment #3)
> Review of attachment 255675 [details] [review]:
> 
> Looks mostly good. How can I run the tests though?

$ make check

> ::: gcr/gcr-parser.c
> @@ +2395,3 @@
> 
> +    if (g_bytes_get_size (data) > 0) {
> +        args.data = g_bytes_ref (data);
> 
> Should there be a corresponding g_bytes_unref in the finalize function?

It's down below at the end of the statement block.

> ::: gcr/tests/test-parser.c
> @@ +266,3 @@
> +    fis = g_file_read (file, NULL, &error);
> +    g_assert_no_error (error);
> +
> 
> Do you want to connect to the "parsed" signal here like in test_parsed_bytes?

Because we're not checking that anything is parsed. I guess I should connect to the "parsed" signal to make sure it gets called.
Comment 5 Stef Walter 2013-09-30 15:03:37 UTC
Created attachment 256096 [details] [review]
gcr: Allow using GBytes with GcrParser

This also solves a corner case where GcrParser would keep around a
pointer to the data passed into gcr_parser_parse_data(), even after
that data had been freed.

gcr_parser_parse_data() now copies the data passed in, where as
the new gcr_parser_parse_bytes() simply keeps a reference to the
GBytes.
Comment 6 Hashem Nasarat 2013-09-30 15:11:54 UTC
Review of attachment 256096 [details] [review]:

Looks good to merge in.
Comment 7 Stef Walter 2013-09-30 15:35:55 UTC
Attachment 256096 [details] pushed as 6924fa9 - gcr: Allow using GBytes with GcrParser