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

GVariant, GError and g_autoptr cleanups #1439

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

swick
Copy link
Contributor

@swick swick commented Sep 23, 2024

No description provided.

Copy link
Contributor

@whot whot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the non-floating gvariants patch but it looks correct and the rest too.

src/input-capture.c Show resolved Hide resolved
In the error case, we will clear the GVariant and then try to emit a
response from a NULL pointer as result. Always create an empty vardict
when something failed instead.

This also clears the error because we continue on in the error case and
do in fact re-using it in one case.
By g_variant_ref_sink'ing floating GVariants as early as possible. This
fixes a few cases where the variant would be leaked, where the floating
ref would be owned by a g_autoptr and makes it easier to see who owns
the reference.

Cases where the floating ref is passed into a function which immediately
sinks the floating ref are left untouched.
@swick
Copy link
Contributor Author

swick commented Oct 4, 2024

I'm convinced that using floating references is in general very dangerous and with g_auto there isn't much of a use for them. The only place where not sinking the floating reference immediately is acceptable in my opinion is when it is passed directly as an argument to a function which is clearly documented to sink the reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

2 participants