Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of GValues containing a floating GObject #506

Merged
merged 1 commit into from Jul 16, 2019

Conversation

@sdroege
Copy link
Member

sdroege commented Jul 16, 2019

We can't simply use g_value_dup_object() and take ownership of the new
reference as on the next opportunity it will be passed to
g_object_ref_sink() in a transfer-none context and that will
accidentally take ownership of the same reference and we get a double
unref() at a later time.

Instead use g_value_get_object(), if the object was floating call
g_object_ref_sink() to sink it and have the GValue as the one and only
owner at this point and then get a new reference for ourselves.

See https://gitlab.gnome.org/GNOME/pygobject/merge_requests/120


CC @MathieuDuponchelle

We can't simply use g_value_dup_object() and take ownership of the new
reference as on the next opportunity it will be passed to
g_object_ref_sink() in a transfer-none context and that will
accidentally take ownership of the same reference and we get a double
unref() at a later time.

Instead use g_value_get_object(), if the object was floating call
g_object_ref_sink() to sink it and have the GValue as the one and only
owner at this point and then get a new reference for ourselves.

See https://gitlab.gnome.org/GNOME/pygobject/merge_requests/120
@sdroege sdroege force-pushed the sdroege:value-get-object-floating branch from 2bb4c86 to 7843029 Jul 16, 2019
Copy link
Member

GuillaumeGomez left a comment

Good catch!

@sdroege sdroege merged commit ffe1549 into gtk-rs:master Jul 16, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.