Commit Graph

24070 Commits

Author SHA1 Message Date
Philip Withnall
0c8f7de55a gdebugcontroller: Add debug controller API and D-Bus implementation
This is intended to provide a uniform interface for controlling whether
the debug output from an application (or service) is emitted, typically
to journald, but actually to wherever the application chooses to output
it.

The main implementation of `GDebugController` is `GDebugControllerDBus`,
which is intended to be used on Linux. Other implementations may be
added in future for other platforms, or larger applications may want to
provide their own implementation which integrates with their ecosystem.

The `GDebugControllerDBus` implementation exposes a D-Bus interface at
`/org/gtk/Debugging` with a method to enable or disable debug
output at runtime.

This could be used by external harnesses, such as GNOME Builder or
systemd, to give a uniform way to get debug output from an application.

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

Fixes: #1190
2022-01-26 15:19:27 +00:00
Philip Withnall
bb4bec0921 gmessages: Expose a property for enabling debug message output
This is an API analogue of the G_MESSAGES_DEBUG environment variable. It
is intended to be exposed outside applications (for example, as a D-Bus
interface — see follow-up commits) so that there is a uniform interface
for controlling the debug output of an application.

Helps: #1190
2022-01-26 15:17:02 +00:00
Milo Casagrande
b4b5b3d029 Update Italian translation 2021-11-09 08:14:26 +00:00
Hugo Carvalho
c57d31288b Update Portuguese translation 2021-11-07 22:14:02 +00:00
Emmanuele Bassi
15aff433cc Merge branch 'fix_pcre' into 'main'
Fix link to pcre-8.37.tar.bz2

See merge request GNOME/glib!2324
2021-11-07 19:45:34 +00:00
Albert Astals Cid
e5dc299701 Fix link to pcre-8.37.tar.bz2
ftp.pcre.org FTP site is no longer available
2021-11-07 20:30:05 +01:00
Yuri Chornoivan
ce093edcc5 Update Ukrainian translation 2021-11-05 18:50:51 +00:00
Philip Withnall
044229e1c1 Merge branch '1109-no-match-rule' into 'main'
gdbusproxy: Add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag

Closes #1109

See merge request GNOME/glib!2322
2021-11-04 14:42:44 +00:00
Philip Withnall
746ce4e042 Merge branch 'fix_garray_warning' into 'main'
Fix always true comparison warning in glib/garray.c

See merge request GNOME/glib!2311
2021-11-04 14:18:03 +00:00
Emmanuel Fleury
12113f398a Fix always true comparison warning in glib/garray.c
glib.git/glib/garray.c: In function ‘g_array_new’:
glib.git/glib/garray.c:184:34: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  184 |   g_return_val_if_fail (elt_size <= G_MAXSIZE / 2 - 1, NULL);
      |                                  ^~
glib.git/glib/gmacros.h:1090:25: note: in definition of macro ‘G_LIKELY’
 1090 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
glib.git/glib/garray.c:184:3: note: in expansion of macro ‘g_return_val_if_fail’
  184 |   g_return_val_if_fail (elt_size <= G_MAXSIZE / 2 - 1, NULL);
      |   ^~~~~~~~~~~~~~~~~~~~
glib.git/glib/garray.c: In function ‘g_array_sized_new’:
glib.git/glib/garray.c:265:34: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  265 |   g_return_val_if_fail (elt_size <= G_MAXSIZE, NULL);
      |                                  ^~
glib.git/glib/gmacros.h:1090:25: note: in definition of macro ‘G_LIKELY’
 1090 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
glib.git/glib/garray.c:265:3: note: in expansion of macro ‘g_return_val_if_fail’
  265 |   g_return_val_if_fail (elt_size <= G_MAXSIZE, NULL);
      |   ^~~~~~~~~~~~~~~~~~~~
2021-11-04 14:50:24 +01:00
Lubomir Rintel
a107a328e4 gdbusproxy: Add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag
D-Bus has an upper limit on number of Match rules and it's rather easy to hit
with a big number of proxies with signal subscriptions. This happens with
NetworkManager with hundreds of devices or connection settings. By passing
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE to g_dbus_connection_signal_subscribe(), the
user can call AddMatch with a less granular match instead of a match per every
proxy.

Tests subsequently added by Philip Withnall.

Fixes: #1109
2021-11-04 11:44:18 +00:00
Michael Catanzaro
caf777984b Merge branch '2426-delayed-settings-null-handling' into 'main'
gdelayedsettingsbackend: Fix applying after calling g_settings_reset()

Closes #2426

See merge request GNOME/glib!2161
2021-11-03 18:03:21 +00:00
Philip Withnall
7be79cb840 Merge branch '2310-xdgmime-leaks' into 'main'
gcontenttype: Ignore intentional one-time leaks from xdgmime

Closes #2310

See merge request GNOME/glib!2268
2021-11-03 15:42:20 +00:00
Philip Withnall
fd080d8564 Merge branch 'list-model-doc-fixes' into 'main'
docs: Fix the GListModel description

See merge request GNOME/glib!2319
2021-11-03 11:46:28 +00:00
Emmanuele Bassi
9500542d78 Merge branch '2520-date-docs' into 'main'
gdate: Clarify the documentation for g_date_new_dmy() and new_julian()

Closes #2520

See merge request GNOME/glib!2318
2021-11-03 11:09:16 +00:00
Philip Withnall
fe0346a172 gdate: Clarify the documentation for g_date_new_dmy() and new_julian()
The documentation about validity did not match the code. Since the code
hasn’t changed in a long time (since 1998 or 2011), change the
documentation to match it.

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

Fixes: #2520
2021-11-03 10:47:38 +00:00
Sebastian Dröge
82be9c4f11 Merge branch 'keyfile-parsing-performance' into 'main'
Keyfile parsing performance improvements

See merge request GNOME/glib!1991
2021-11-02 11:08:15 +00:00
Philip Withnall
513f48bab7 gkeyfile: Rework preconditions to avoid unreachable branches
It’s a programmer error for `NULL` to reach `is_group_name()` or
`is_key_name()`, so rework the preconditions so that all programmer
error checks are wrapped in a `g_return_if_fail()`. The coverage
scanning is set up to ignore anything inside that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
e8a6d0b54e tests: Test various different invalid encoding names for key files
These exercise different branches in
`g_key_file_parse_key_value_pair()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
d2e5c61104 tests: Use g_assert_*() rather than g_assert() in keyfile.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
655e2bac33 gkeyfile: Remove some redundant checks
`g_key_file_parse_key_value_pair()` checks that both of these are
non-NULL on entry, and they can’t be modified between then and here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f471afb646 gkeyfile: Clarify behaviour of locales and checked_locales
This should introduce no functional changes, but will remove an
unreachable branch in `g_key_file_locale_is_interesting()`:
`checked_locales` indicates whether `locales` has been initialised (and
it can be initialised to `NULL`), so there’s no point in checking
`locales` itself if `checked_locales` is checked.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f93f24e41c gkeyfile: Avoid allocating a copy of the locale for a key
Instead compare it inline. This should avoid a lot of allocations in key
files with lots of translations (such as desktop files).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
5a38dc79f0 gkeyfile: Move allocation of value until after locale checks have passed
This avoids allocating a copy of the value in the case that it’s for a
locale which is uninteresting.

This should speed up parsing of key files with large numbers of
translations, when only the translations for certain locales are wanted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
6c70d30f07 gkeyfile: Tidy up ownership transfer in parse_key_value_pair()
This introduces no functional changes, but does make the ownership
transfer a little clearer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
cdcc06bbc5 gkeyfile: Move allocation of value until after error checking
This doesn’t affect performance in the normal case of a valid key file,
but does improve performance when handling largely-invalid key files.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
b07408fe5d gkeyfile: Fix off-by-one error in calculating value length
This was harmless, as it was always +1 too long, so included the
trailing nul terminator. However, upcoming changes will start to use it
in a context where there is no nul terminator.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
535653eec1 gstrfuncs: Document that g_ascii_strncasecmp() stops at first nul byte
The documentation wasn’t clear about whether it did that, or ignored nul
bytes and continued to `n` bytes regardless.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
c29601818f gkeyfile: Eliminate strcmp()s when looking up a group node
Rather than looking for the group node by comparing each name in the
linked list of `GKeyFileGroup` instances, look up the `GKeyFileGroup` in
the hash table, then look up its `GList` node by pointer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
cba8d59737 gkeyfile: Eliminate unnecessary allocations when setting booleans
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f71db39284 gkeyfile: Avoid an unnecessary strcmp()
As the groups are disambiguated by name via the `groups` hash table,
there is guaranteed to be at most one `GKeyFileGroup` instance per group
name, which means they can be compared for equality by `GKeyFileGroup`
pointer, rather than needing a `strcmp()`.

This speeds up key file parsing in all cases.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
960030712d gkeyfile: Add a length argument to is_key_name()
This allows it to be called on a substring of a larger string, without
having to allocate a nul-terminated copy of the substring with
`g_strndup()` before knowing that the key name is actually valid.

This speeds up parsing of highly invalid key files, but doesn’t affect
performance in the normal case of a valid key file.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:33 +00:00
Philip Withnall
1161bd8078 Merge branch 'drop-old-xdgmime-change' into 'main'
Revert "Don't compile some unused functions in gio/xdgmime/"

See merge request GNOME/glib!2277
2021-11-02 09:28:22 +00:00
Anders Jonsson
e045675d80 Update Swedish translation 2021-11-01 20:49:52 +00:00
Philip Withnall
e4288ef9d7 Merge branch 'pcre' into 'main'
Rename libpcre.wrap to pcre.wrap

See merge request GNOME/glib!2309
2021-11-01 19:07:37 +00:00
Emmanuele Bassi
192b3e6c2d docs: Fix the GListModel description
- Isolate the first meaningful paragraph, for gi-docgen's summary
- Describe get_object() as a binding API
- Fix reference to get_item() inside get_item_type()
2021-11-01 18:41:50 +00:00
Philip Withnall
48af1cbddc Merge branch 'source-attach-trigger-wakeup' into 'main'
Add g_main_context_new_with_flags() and ownerless polling option

See merge request GNOME/glib!1960
2021-11-01 18:39:56 +00:00
Philip Withnall
726c44c348 Merge branch '2400-dbus-race' into 'main'
gdbusconnection: Fix race between method calls and object unregistration

Closes #2400

See merge request GNOME/glib!2265
2021-11-01 18:37:17 +00:00
Philip Withnall
40f995e0aa Merge branch 'editorconfig' into 'main'
docs: Add .editorconfig file

See merge request GNOME/glib!2191
2021-11-01 18:36:38 +00:00
Xavier Claessens
9a9f6b5a4b Rename libpcre.wrap to pcre.wrap
It is exactly the same wrap as the one in WrapDB but with a different
name. That fix error when multiple projects uses pcre and they don't
have the same wrap name:

meson.build:1:0: ERROR: Multiple wrap files provide 'libpcre' dependency: pcre.wrap and libpcre.wrap
2021-11-01 18:22:26 +00:00
Philip Withnall
46fe9639b9 gkeyfile: Make various parsing variables const
All these `gchar *`s are used as moving pointers into strings, being
incremented as the strings are parsed. They are never modified, so can
be `const`. This doesn’t speed anything up, but does allow removing some
casts and slightly improving type safety.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-01 18:16:27 +00:00
Yuri Chornoivan
f6b86790e3 Update Ukrainian translation 2021-11-01 17:52:22 +00:00
Philip Withnall
32b034a0aa Merge branch 'setuid-wording' into 'main'
gdbusaddress: setuid error message references AT_SECURE

Closes #2518

See merge request GNOME/glib!2315
2021-11-01 17:23:22 +00:00
Pablo Correa Gómez
14c5589ed6
gdbusaddress: setuid error message references AT_SECURE
g_check_setuid does more than setuid checks when using AT_SECURE.
Make sure that it is referenced in the error message to help
users debug in case or errors

Closes #2518
2021-11-01 15:54:55 +01:00
Philip Withnall
3dcae415a4 Revert "Don't compile some unused functions in gio/xdgmime/"
This reverts commit 14e46ca288.

Diverging from upstream xdgmime is a maintenance burden, and this
isn’t really much additional code to compile. It should be dropped by
the linker since it’s unused.

See https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/15.
2021-11-01 12:06:26 +00:00
Philip Withnall
e4bb09d8ec Merge branch 'fix-win32-app-info-registry-key-assert' into 'main'
GWin32AppInfo: Do not assert about successful open'ing of registry keys

See merge request GNOME/glib!2260
2021-11-01 10:41:31 +00:00
Philip Withnall
34ce204fd7 tests: Add D-Bus object/subtree unregistration tests
These tests cover the fixes from the previous two commits.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
117b748e44 gdbusconnection: Fix race between subtree method call and unregistration
Fix another variant of the previous commit, this time specific to the
idle callback of a method call on a subtree object, racing with
unregistration of that subtree.

In this case, the `process_subtree_vtable_message_in_idle_cb()` idle
callback already has a pointer to the right `ExportedSubtree` struct,
but again doesn’t have a strong reference to it.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
50fbf05d61 gdbusconnection: Fix race between method calls and object unregistration
If `g_dbus_connection_unregister_object()` (or `unregister_subtree()`)
was called from one thread, while an idle callback for a method call (or
a property get or set) was being invoked in another, it was possible for
the two to race after the idle callback had checked that the
object/subtree was registered, but before it had finished dereferencing
all the data related to that object/subtree.

Unregistering the object/subtree would immediately free the data,
leading the idle callback to cause a use-after-free error.

Fix that by giving the idle callback a strong reference to the data from
inside the locked section where it checks whether the object/subtree is
still registered.

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

Fixes: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
c8c2ed4af5 gdbusconnection: Make ExportedInterface/ExportedSubtree refcounted
This is needed for an upcoming change which decouples their lifecycle
from their presence in the `map_id_to_ei` and `map_id_to_es` hash
tables.

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

Helps: #2400
2021-10-28 14:53:48 +01:00