g_win32_fs_monitor_handle_event() converts the new name of a rename
to UTF-8 and passes it to g_file_monitor_source_handle_event(), which
takes it as const and copies what it keeps. Nothing freed it, so every
reported rename leaked the string.
I have no idea what I’m doing, and I don’t have access to a FreeBSD
system except via CI.
This implementation is based off the information on
https://frasertweedale.github.io/blog-fp/posts/2021-01-01-fixing-getExecutablePath-FreeBSD.html.
It’s possible that this implementation will work fine on other BSDs, but
since we only have a *Free*BSD CI box to test against, that’s the
platform which I’ve conditionalised this on for now.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #4073
Rather than looking up the file system type with a 100-element `switch`
block, use `bsearch()`. At higher optimisation levels, modern GCC can
unwrap libc’s `bsearch()` and inline the comparison function, reducing
about 400 comparison/jump instructions to less than 30 implementing the
binary search.
See https://godbolt.org/z/cn88aado5
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Currently `g_desktop_app_info_ensure_saved()` assumes that if the object
does not have a filename, it was created with
`g_app_info_create_from_commandline()`, and therefore assumes
`info->exec`, `info->name` and `info->comment` are not NULL.
However, app info could have been also created with
`g_desktop_app_info_new_from_keyfile()`, which does not guarantee any of
those values. This results in failed assertions and broken resulting
filename, if these keys are not set in the key file.
The Name key is required by the Desktop Entry Specification, so make
`g_desktop_app_info_new_from_keyfile()` error out when the name is
missing, and check the remaining values in
`g_desktop_app_info_ensure_saved()`.
On AIX and IBM i, `recvmmsg()` and `sendmmsg()` aren't properly exposed by
system headers: they are declared (under an `#ifdef _KERNEL` guard) but not
defined in the public symbol tables.
OpenSSL had the same issue:
https://github.com/openssl/openssl/issues/30806 and was forced not to use those
functions on these platforms (commit
4a5a074943).
Update `meson.build` to check more carefully for whether these two functions are
usable, rather than just scanning for declarations in the headers.
The upcoming meson 1.13.0 release will make g-ir-scanner warnings
fatal when `meson setup --werror` is used. This commit sets
`fatal_warnings: false` for steps with existing introspection
warnings so --werror can continue to be used for compiler warnings.
Bug #3251 tracks the work needed to enable fatal_warnings for
girepository.
g_action_group_query_action() sets parameter_type to NULL for actions
without a parameter, state_type and state to NULL for stateless
actions, and state_hint to NULL when there is no hint. The matching
g_action_group_get_action_*() getters already mark these results as
nullable.
A successful g_file_enumerator_iterate() call returns NULL outputs at
exhaustion. Optional output locations and borrowed result lifetimes
remain unchanged.
Currently `g_desktop_app_info_set_as_default_for_type()` and
`g_desktop_app_info_set_as_last_used_for_type()` check if application's
ID is NULL, and error out accordingly.
This is because back when this mechanism was introduced in
229234111c,
app infos created with `g_desktop_app_info_new_from_filename()` would not
have application's ID set. However, since
c0af442909
and then
f065497acf
the application's ID is expected not to be empty. Moreover,
`g_desktop_app_info_ensure_saved()` guarantees it's set if it returns
true, so the error can never be returned.
Drop the unused check and error in those cases.
If we are using libffi to trampoline then there is opportunity to cache
the ffi_call_plan introduced in newer libffi releases. A rather contrived
test introduced in the previous commit includes a basic performance test
that can compare between versions.
For my system, the average call time dropped from 200ns/call to 145ns/call
for cached GClosure. Since the previous version did no caching, the
uncached GClosure use was also just slightly slower around 205ns/call. For
the cached form (since it can reuse a global plan cache via GMutex) it
drops to 180ns/call. So that is 27.5% savings and a 10% savings in runtime
duration.
Closes: #4002
Co-authored-by: Philip Withnall <pwithnall@gnome.org>
The goal here is to get a baseline for upcoming performance work
to use the cached libffi plans rather than generating a new plan
on every pass through libffi.
- Factor the core spawning logic into an internal helper.
- Add g_desktop_app_info_launch_uris_with_spawn_async() and _finish()
to handle their own GTask lifecycle, cancellation, and D-Bus flushing.
- Retain g_desktop_app_info_launch_uris_with_spawn() as a synchronous wrapper
for existing sync callers.
- Update launch_uris_bus_get_cb() to delegate to the async variant instead of
calling the synchronous spawn function.
Instead of calling g_dbus_connection_flush() in callers such as
g_desktop_app_info_launch_uris_internal() and
g_desktop_app_info_launch_action(), move the flush into
g_desktop_app_info_launch_uris_with_spawn().
This makes g_desktop_app_info_launch_uris_with_spawn() self-contained
in flushing the startup notification D-Bus messages it emits.
The flush was originally added in commit d6954c78 specifically to ensure
that fire-and-forget D-Bus signals emitted for startup notification
(notify_desktop_launch()) were not dropped if the session bus connection
was unreffed immediately afterwards.
Because notify_desktop_launch() is only called in the spawn path, the
other callers do not emit startup notification signals. The D-Bus
activation paths (g_desktop_app_info_launch_uris_with_dbus() and
g_desktop_app_info_launch_action()) use method calls whose lifecycle is
managed by GTask (which holds a reference to the connection until
complete), so they do not require an explicit flush.
g_value_reset() returns the GValue passed in, so ownership of the
storage stays with the caller. Annotate the return value as borrowed
to prevent introspection consumers from treating it as newly owned.
`(transfer floating)` is an alias for `(transfer none)`, so most of
these changes are no-ops. But they will allow the introspection data to
be more correct when gobject-introspection eventually gains full support
for floating values.
In the case of `g_variant_new()` and `g_variant_new_va()`, this is an
introspection annotation change as previously they were implicitly
`(transfer full)`. That’s fine though as they’re both already marked as
`(skip)` so this won’t affect bindings in practical terms.
Spotted in !5405.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
`g_variant_builder_end()` returns a new floating reference. We don’t
want to pass a floating reference into the `before_emit()` and
`after_emit()` vfuncs, in case they sink it, so let’s sink it first and
then unref later to avoid the leak.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #4072
The previous implementation incorrectly relied on
g_win32_get_package_installation_directory_of_module(), which is
designed to find the package root prefix (stripping subdirectories
like `bin/` or `lib/`).