Commit Graph

31151 Commits

Author SHA1 Message Date
Philip Withnall
4641535596
Revert "gdbus: Fix leak of method invocation when registering an object with closures"
This reverts commit 092fedd5f0.

This was not the right change to make, and I shouldn’t have accepted the
MR. The situation is laid out in this comment:
https://gitlab.gnome.org/GNOME/glib/-/issues/2600#note_1385050

tl;dr: The reference on the `GDBusMethodInvocation` which is transferred
in to the `GDBusInterfaceMethodCallFunc` is balanced by a reference
transferred to `g_dbus_method_invocation_return_*()`. This is how the
refcounting has always worked for these functions, and even if we’d
probably arrange things differently if the code was written now, we
can’t change those semantics without breaking API.

In particular, bindings have various bits of custom code to account for
these reference tranfers (since they can’t be represented using
gobject-introspection annotations), so changing the semantics will break
bindings.

Fixes: #3559
2024-12-10 15:53:54 +00:00
Michael Catanzaro
a5f68ba494 Merge branch '3538-dbus-appinfo-hurd' into 'main'
tests: Skip unsupported dbus-appinfo test on GNU/Hurd for the moment

See merge request GNOME/glib!4425
2024-12-10 14:24:52 +00:00
Philip Withnall
8c3fda5c8d
tests: Skip unsupported dbus-appinfo test on GNU/Hurd for the moment
Parts of the `dbus-appinfo` test need support for converting an FD to a
path, and Hurd doesn’t currently allow that (see
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4396#note_2279923).

Since there’s no fix for that visible in the medium term (new kernel
APIs will need to be added), skip parts of the `dbus-appinfo` test which
require that functionality for now.

This prevents the whole test from failing, and means we can usefully get
results from the parts of it which don’t depend on converting FDs to
paths.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3538
2024-12-10 11:47:43 +00:00
Michael Catanzaro
7705bbe8fc Merge branch 'ci-quoting' into 'main'
ci: Ensure all variables are quoted in .gitlab-ci.yml

See merge request GNOME/glib!4424
2024-12-09 14:33:55 +00:00
Michael Catanzaro
c5f9eb51a2 Merge branch 'gio-tool-mount-docs' into 'main'
gio-tool: Clarify that `gio mount -l` only lists user-interesting things

See merge request GNOME/glib!4423
2024-12-09 14:32:21 +00:00
Philip Withnall
eecacf7053 Merge branch 'document-constructed' into 'main'
gparam: Add link to constructed vfunc to CONSTRUCT

See merge request GNOME/glib!4421
2024-12-09 11:12:12 +00:00
Philip Withnall
628d623b57
ci: Ensure all variables are quoted in .gitlab-ci.yml
Don’t want any argument escaping problems, given that some of these
variables can be controlled by unprivileged users who are running CI
jobs.

The except:variables and rules:if lines don’t need to be quoted because
they are [GitLab CI/CD Variable
Expressions](https://docs.gitlab.com/ee/ci/jobs/job_rules.html#cicd-variable-expressions)
rather than bash script.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-08 23:57:34 +00:00
Philip Withnall
f5941d3284 Merge branch 'bugfix/gsettings-schema-has-key' into 'main'
Fix g_settings_schema_has_key() to work with extended schemas

Closes #3548

See merge request GNOME/glib!4420
2024-12-08 23:09:13 +00:00
Philip Withnall
fa33e232d2
gio-tool: Clarify that gio mount -l only lists user-interesting things
It doesn’t list all mounts, only the ones you’d expect to see in a file
chooser sidebar.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3555
2024-12-08 23:03:07 +00:00
Martin Domig
70fe6839a5 Fix typo in test_extended_schema
Signed-off-by: Martin Domig <martin.domig@wolfvision.net>
2024-12-08 22:15:03 +01:00
Martin Domig
d63d27b195 Add test for g_settings_schema_has_key on extended schema
The test checks that the keys of the base schema do all exist in the
extended schema.

Signed-off-by: Martin Domig <martin.domig@wolfvision.net>
2024-12-08 22:13:51 +01:00
Michael Catanzaro
1bd1c912d3 Merge branch 'fix-link-contributing' into 'main'
docs: Fix dead link in CONTRIBUTING

See merge request GNOME/glib!4422
2024-12-07 14:01:24 +00:00
Rebecca N. Palmer
2ae3dc6b8c docs: Fix dead link in CONTRIBUTING 2024-12-07 10:54:25 +00:00
Maximiliano Sandoval
c1fcc7be49
gparam: Add link to constructed vfunc to CONSTRUCT
The docs for the constructed vfunc make it clear that when called
constructed properties are already set. However, the first place where a
user would look for is the flag's documentation.
2024-12-06 18:07:47 +01:00
Johannes Marte
58f9667def GSettingsSchema: fix g_settings_schema_has_key()
A settings schema that extends another schema should return TRUE for
all keys that are present in the extended schema. The list of keys
returned by list_keys() already includes these,
so it makes sense to include them in has_key().

Signed-off-by: Johannes Marte <johannes.marte@wolfvision.net>
2024-12-06 08:06:18 +01:00
Philip Withnall
f06352f841 Merge branch 'fix-3552' into 'main'
gmessages: Add nullable annotation for `log_domain` in `GLogFunc`

Closes #3552

See merge request GNOME/glib!4419
2024-12-05 18:24:04 +00:00
Roberto Leinardi
78b4b66e9a
gmessages: Clarify log_domain behavior in function descriptions
Move details about the `log_domain` parameter being `NULL` or an empty string
for the default application domain from argument descriptions to the main
function descriptions.

This ensures concise argument descriptions while providing a clear
explanation of exceptions in the function body.
2024-12-05 17:19:27 +01:00
Roberto Leinardi
1691657cb3
gmessages: Add nullable annotation for log_domain in GLogFunc
Add a missing `(nullable)` annotation for the `log_domain` parameter in the
`GLogFunc` callback. This ensures consistency with the documentation and
usage in functions like `g_log_set_handler`, where `log_domain` can be `NULL`.

Without this annotation, the GIR file generated from the C source does not
reflect the nullability of `log_domain`, leading to potential issues in
language bindings and other introspection-based tools.

This change updates the documentation in `glib/gmessages.c` to include the
nullable annotation and clarifies the expected behavior of the `GLogFunc`
callback.

Fixes #3552
2024-12-05 17:19:19 +01:00
Philip Withnall
b6da230b8f Merge branch 'find_signal_avoid_alloc' into 'main'
girepository: gi_object_info_find_signal(): Avoid repeated allocations

See merge request GNOME/glib!4382
2024-12-05 10:47:57 +00:00
Philip Withnall
f3a82ba866 Merge branch 'gdbus-missing-nullable' into 'main'
gdbus: Add a few missing `(nullable)` annotations to GDBus method invocation related functions

See merge request GNOME/glib!4414
2024-12-04 08:37:40 +00:00
Philip Withnall
106dc2f902 Merge branch 'thread-get-name' into 'main'
Add g_thread_get_name

Closes #3546

See merge request GNOME/glib!4408
2024-12-03 08:06:18 +00:00
Matthias Clasen
5b53337432 Add g_thread_get_name
This is meant to improve debugging of thread-related problems outside
of GLib. This commit adds an implementation for Posix. The Win32
implementation is a stub.

Test included.

Fixes: #3546
2024-12-03 08:06:17 +00:00
Sebastian Dröge
f5678377c0 gdbus: Add a few missing (nullable) annotations to GDBus method invocation related functions
Sender can be NULL if not specified by the caller, e.g. on peer-to-peer
connections.

Interface name can be NULL on method calls if it was not specified by
the sender.

Both is explicitly allowed by the DBus specification.
2024-12-03 06:22:52 +00:00
Philip Withnall
8f26f904c4 Merge branch 'fix-signal-connect-docs' into 'main'
gsignal: Add clarification on 'detailed_signal' validation

Closes #3540

See merge request GNOME/glib!4416
2024-12-03 06:05:42 +00:00
Sid
56b261d8cf gsignal: Add clarification on 'detailed_signal' validation
Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3540
2024-12-03 06:05:42 +00:00
Philip Withnall
ae946acb81 Merge branch 'gdbus-register-object-with-closures-memleak' into 'main'
gdbus: Fix leak of method invocation when registering an object with closures

See merge request GNOME/glib!4415
2024-12-02 16:46:17 +00:00
Sebastian Dröge
092fedd5f0 gdbus: Fix leak of method invocation when registering an object with closures
The invocation passed in is owned by the callback.
2024-12-02 16:46:17 +00:00
Philip Withnall
309ef1977f Merge branch 'fix-signal-connect-docs' into 'main'
gsignal: Add clarification on 'detailed_signal' validation

Closes #3540

See merge request GNOME/glib!4416
2024-12-02 14:28:59 +00:00
Sid
0a68b172be gsignal: Add clarification on 'detailed_signal' validation
Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3540
2024-12-02 14:28:59 +00:00
Philip Withnall
c50836535a Merge branch 'debug-invocation' into 'main'
gmessages: Treat DEBUG_INVOCATION=1 same as G_MESSAGES_DEBUG=all

See merge request GNOME/glib!4412
2024-11-29 16:13:02 +00:00
Philip Withnall
b180a8ec70 Merge branch 'threadpool-thread-naming' into 'main'
threadpool: Simplify pool thread naming

See merge request GNOME/glib!4410
2024-11-27 21:56:16 +00:00
Matthias Clasen
eea697d523 threadpool: Simplify pool thread naming
In my experience, it isn't actually useful to have the program
name as part of the thread name (we don't do that for other threads
that we create: pool-spawner, gmain, gdbus, ...) and the size limit
of 16 means that there really isn't enough space for it.

But what is somewhat useful is to have different threads have different
names, so number the pool threads: pool-0, pool-1, ...
2024-11-27 21:56:16 +00:00
Philip Withnall
4f7ba235ea Merge branch 'unicode16' into 'main'
gunicode: Update some comments in gunicode.h for Unicode 16.0.0

See merge request GNOME/glib!4413
2024-11-27 16:34:27 +00:00
Peng Wu
c2be38ec50 gunicode: Update some comments in gunicode.h for Unicode 16.0.0 2024-11-27 16:34:27 +00:00
Philip Withnall
5198798f9a
tests: Port logging tests to use g_test_trap_subprocess_with_envp()
`g_setenv()` is unsafe to use after any other threads have started,
which might have happened once GLib is initialised.

Avoid that problem by using `g_test_trap_subprocess_with_envp()` to
launch the existing subprocesses with the desired environment. This API
was added after these tests were written, but it’s a perfect fit for
them.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-27 16:10:53 +00:00
Philip Withnall
8b29c53057
gmessages: Treat DEBUG_INVOCATION=1 same as G_MESSAGES_DEBUG=all
systemd 257 will now set `DEBUG_INVOCATION=1` in the execution context
of services which need to be debugged — for example if they’ve failed
and been restarted (and `RestartMode=debug`).

If we handle `DEBUG_INVOCATION=1` as being equivalent to
`G_MESSAGES_DEBUG=all`, then any processes using GLib’s default log
writer function (or `g_log_writer_default_would_drop()`) automatically
gains support for this feature.

See https://mastodon.social/@pid_eins/113548825942383777

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-27 16:10:22 +00:00
Philip Withnall
c64f82fa79 Merge branch 'wip/pwithnall/procfs-refactor' into 'main'
tests: Factor out a function to convert FD to path

See merge request GNOME/glib!4396
2024-11-26 12:06:28 +00:00
Philip Withnall
f72c1690f8 Merge branch 'threadpool-max-unused' into 'main'
threadpool: Increase default for max_unused_threads

Closes #3545

See merge request GNOME/glib!4409
2024-11-26 11:45:45 +00:00
Matthias Clasen
9f6441b278 threadpool: Increase default for max_unused_threads
The default value for max_unused_threads has been 2 since 2012.
Core counts have gone up since then, and nowadays, it would be
much better to keep more of the threads alive for a little while.

This commit bumps the max_unused_threads default value to 8.

Fixes: #3545
2024-11-26 11:45:44 +00:00
Philip Withnall
c00c36be3b Merge branch 'allow_dbus_cross_ns' into 'main'
gdbusconnection: Allow creating connection with cross-namespace

See merge request GNOME/glib!4411
2024-11-26 11:22:55 +00:00
Philip Withnall
05e60ee29c Merge branch 'allow_dbus_cross_ns' into 'main'
gdbusconnection: Allow creating connection with cross-namespace

See merge request GNOME/glib!4411
2024-11-26 11:16:36 +00:00
Philip Withnall
fcc0e4d556 Merge branch 'uri-double-slash-path' into 'main'
guri: Fix paths starting with ‘//’ when parsing

See merge request GNOME/glib!4407
2024-11-26 11:08:12 +00:00
tytan652
9335698b87 gdbusconnection: Allow creating connection with cross-namespace 2024-11-25 17:42:27 +01:00
Barnabás Pőcze
7a528d0ff0 girepository: gi_object_info_find_signal(): Avoid repeated allocations
Previously `gi_object_info_find_signal()` used `gi_object_info_get_signal()`
to retrieve the *i*th signal and compare its name to the desired name.
However, `gi_object_info_get_signal()` returns an allocated object.
If the names were not matching, the allocated object was simply dropped,
and this resulted in a lot of unnecessary allocations compared to the
desired number of allocations, which is one.

To avoid much of the overhead pertaining to the creation of these allocated
`GISignalInfo` objects, introduce a new function that inspects the signal
blobs directly and returns an allocated `GISignalInfo` object just for the
matching signal. The function is largely a copy-and-paste of `gi_base_info_find_vfunc()`,
which does the same thing, only for virtual functions.

See https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/504
2024-11-23 19:25:17 +01:00
Philip Withnall
2713d68ad2
guri: Fix paths starting with ‘//’ when parsing
This fixes cases where calling `g_uri_to_string()` immediately after a
successful call to `g_uri_parse()` would cause an assertion failure for
URIs like `data:/.//` or `data:.///`.

These appear to be valid URIs. Their paths are normalised to `//` during
parsing as a result of the `remove_dot_segments()` algorithm. This then
falls foul of the restriction from
https://datatracker.ietf.org/doc/html/rfc3986#section-3 that

> When authority is not present, the path cannot begin with two slash
> characters ("//").

This is already encoded in an assertion at the top of
`g_uri_join_internal()`.

The approach of prefixing the path with `/.` should be harmless: it
guarantees the path starts with `/`, prevents `//` being a prefix, and
should always be removed by `remove_dot_segments()` when re-parsing the
URI. It’s the same approach as taken in the WhatWG URL spec for a
similar (but different) situation:
https://url.spec.whatwg.org/#url-serializing (see step 3).

See also: https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/415?commit_id=79cfd65c9bd8024cd45dd725c284766329873709

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-23 11:54:34 +00:00
Philip Withnall
2b155f86dd Merge branch 'update-macos-min' into 'main'
Raise minimum supported macOS version to 10.13 (High Sierra)

Closes #3441

See merge request GNOME/glib!4405
2024-11-21 11:13:04 +00:00
John Ralls
9bbb1acd7d Raise minimum supported macOS version to 10.13 (High Sierra).
Allows removing all macOS version ifdefs.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/3441
2024-11-20 18:15:34 -08:00
Michael Catanzaro
b21bc8d49f Merge branch 'wip/hughsie/gbytes-null' into 'main'
glib/gbytes: Be more careful when saving a GBytes of NULL

See merge request GNOME/glib!4406
2024-11-20 16:08:40 +00:00
Richard Hughes
9ddc97314b
glib/gbytes: Be more careful when saving a GBytes of NULL
In 1e3b010 the behaviour of `g_bytes_new (NULL, 0)` was changed; before the
`g_bytes_get_data()` would return NULL as expected, but now it returns a pointer
outside the single GBytes allocation.

This breaks the fwupd self tests as we use a GBytes of NULL to signify that
the emulation data exists, but it has no content.

Catch this case and restore the old behaviour.
2024-11-20 14:06:36 +00:00
Michael Catanzaro
3e87611232 Merge branch 'wip/pwithnall/3493-unicode-with-strlen' into 'main'
gutf8: Drop ifunc code and always call strlen() when validating UTF-8

Closes #3493, #3511, and #3526

See merge request GNOME/glib!4404
2024-11-19 20:53:26 +00:00