Commit Graph

26622 Commits

Author SHA1 Message Date
Michael Catanzaro
4d172a2015 Revert "gthread: Only print scheduler setting warnings once"
This reverts commit c8840ff9a8.
2022-12-12 12:39:25 -06:00
Marco Trevisan (Treviño)
5dc8d2ca00 gtype: Simplify g_type_test_flags() for node flags checks only
And this will affect G_TYPE_IS_FINAL, G_TYPE_IS_CLASSED,
G_TYPE_IS_INSTANTIATABLE and mixes of them.
2022-12-12 19:03:48 +01:00
Matthias Clasen
a31b042dfc gtype: Speed up type checking for final types
Store the final flag directly in the TypeNode,
so we can get it cheaply, and use it to speed
up g_type_instance_is_a for final types.
2022-12-12 19:03:48 +01:00
Marco Trevisan (Treviño)
6a0591f06c gobject/tests/type-flags: Add tests for type final type flags
Ensure that final flag is properly checked and used.
2022-12-12 19:03:48 +01:00
Marco Trevisan
7bb0261407 Merge branch 'ebassi/notify-queue-finalize-warning' into 'main'
Improve notification queue warning

See merge request GNOME/glib!3119
2022-12-12 16:01:59 +00:00
Emmanuele Bassi
fde157ace4 Improve notification queue warning
Instead of a plain reference count check failure that is really hard to
understand, let's be explicit, and warn that manipulating an object's
notification queue during its finalization is not allowed.
2022-12-12 15:01:19 +00:00
Marco Trevisan (Treviño)
511d1cad02 gdesktopappinfo: Fail early if trying to launch an invalid executable
GDesktopAppInfo never failed in the most simple of the cases: when a
desktop file or a command line app info was pointing to an invalid
executable (for the context).

The reason for this is that we're launching all the programs using
gio-launch-desktop which will always exist in a sane GLib installation,
and thus our call to execvp won't ever fail on failure.

This was partially mitigated by not allowing to create a desktop app
icon using a non-existent executable (even if not fully correctly) but
still did not work in case a custom PATH was provided in the launch
context.

To avoid this, use g_find_program_for_path() to find early if a program
that we're about to launch is available, and if it's not the case return
the same error that g_spawn_async_with_fds() would throw in such cases.

While this is slowing a bit our preparation phase, would avoid to leave
to the exec function the job to find where our program is.

Add tests simulating this behavior.
2022-12-12 15:58:13 +01:00
Marco Trevisan (Treviño)
da8aa0b66d desktop-app-info: Use launch context PATH and desktop Path to find terminals
We used to launch applications with terminals using the normal program
finder logic that did not consider the context path nor the desktop file
working dir. Switch to g_find_program_for_path() to find terminals so we
can ensure that both conditions are true.

Update tests to consider this case too.
2022-12-12 15:58:13 +01:00
Marco Trevisan (Treviño)
e41e3dc601 gdesktopappinfo: Take in account the desktop Path to find executables
Desktop files can provide the executable working path and that can be
used to pick the file to launch.

So take it in account.
2022-12-12 15:58:13 +01:00
Marco Trevisan (Treviño)
7bac92a2bb gutils: Split g_find_program_path() to make it more flexible and testable
Split g_find_program_path() in g_find_program_for_path() that supports
passing path arguments and providing a custom working directory.

Adding tests to cover the cases we were not doing before.
2022-12-12 15:58:13 +01:00
Philip Withnall
34618aea70 Merge branch 'gdbinit' into 'main'
tests: fix assert-msg-test with custom gdbinit

See merge request GNOME/glib!3117
2022-12-12 14:01:47 +00:00
Philip Withnall
7cd0750a41 Merge branch 'spawn-check-privfds' into 'main'
glib/spawn: check user source_fds doesn't contain private fds

See merge request GNOME/glib!2479
2022-12-12 13:53:59 +00:00
Marc-André Lureau
5f21c8da1c glib/tests: add /gthread/spawn-async-with-invalid-fds
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-12-12 17:41:12 +04:00
Marc-André Lureau
d8448636b4 glib/spawn: check user source_fds doesn't contain private fds
If the user provided source_fds set contains internal fds, this is a
programmer mistake. We can avoid further damage by preventing this
situation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-12-12 11:28:58 +04:00
Marc-André Lureau
13acc3176b tests: fix assert-msg-test with custom gdbinit
As recommended by GDB on Fedora, I have "set debuginfod enabled on" in
my .gdbinit. However, this make assert-msg-test time out.

Let's ignore user gdbinit for the test, as this shouldn't be required
and can easily break the test.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-12-12 10:53:47 +04:00
Olga Smirnova
8df369612d Add Interlingue translation
(cherry picked from commit 17672aeb4d)
2022-12-12 00:16:24 +00:00
Philip Withnall
0f6f5d0b3a Merge branch 'ebassi/no-hacking' into 'main'
docs: Remove HACKING

See merge request GNOME/glib!3116
2022-12-09 15:25:09 +00:00
Emmanuele Bassi
a9d75f19e7 docs: Remove HACKING
The process of contributing to GLib is already outlined in the
contribution guide, and the HACKING file is just referencing out of date
dependencies.
2022-12-09 12:25:40 +00:00
Philip Withnall
febe922602 Merge branch '1904-action-crashes' into 'main'
gaction: Validate actions activated over D-Bus

Closes #1904

See merge request GNOME/glib!3113
2022-12-09 11:04:02 +00:00
Philip Withnall
191e89878d tests: Add basic GApplicationCommandLine unit tests
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-09 10:45:21 +00:00
Philip Withnall
c0eef5e226 gapplication: Validate types of well-known platform data keys
The platform data comes from the parent process, which should normally
be considered trusted (if we don’t trust it, it can do all sorts of
other things to mess this process up, such as setting
`LD_LIBRARY_PATH`).

However, it can also come from any process which calls `CommandLine`
over D-Bus, so always has to be able to handle untrusted input. In
particular, `v`-typed `GVariant`s must always have their dynamic type
validated before having values of a static type retrieved from them.

Includes unit tests.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
eb0d9e709a gapplication: Document that command line options must be validated
They come from an external process, so they must be validated.

In particular, it’s always easy to forget to validate the type of a
`GVariant`, and just try to get the stored value using a well-known
type; but that’s a programming error if the `GVariant` actually stores a
different type. Always check the variant type first if loading from a
`v`.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
83c11637ba gfdonotificationbackend: Validate actions before activating them
These actions are activated as a result of receiving the `ActionInvoked`
signal from `org.freedesktop.Notifications`. As that’s received from
another process over D-Bus, it’s feasible that it could be malformed.
Without validating the action and its parameter, assertions will be hit
within the `GAction` code.

While we should be able to trust whatever process owns
`org.freedesktop.Notifications`, it’s possible that’s not the case, so
best validate what we receive.

Includes unit tests.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
08012bd3e0 tests: Add stub tests for GFdoNotificationBackend
This test is fairly pointless, but puts the infrastructure in place for
adding more tests for `GFdoNotificationBackend` in upcoming commits.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
3987f41f8c gfdonotificationbackend: Don’t remove notification if invoking action fails
Invoking an action on a notification should remove it (by default,
unless the `resident` hint is set, but GLib doesn’t currently support
that).

If, somehow, an invalid action is invoked on the notification, that
shouldn’t cause it to be removed though, because no action has taken
place. So change the code to do that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-09 10:45:21 +00:00
Philip Withnall
da634e7a25 gapplication: Validate actions activated over D-Bus
As with the previous commit, the arguments to `ActivateAction` have to
be validated before being passed to `g_action_group_activate_action()`.
As they come over D-Bus, they are coming from an untrusted source.

Includes unit tests for all D-Bus methods on `GApplication`.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
dbe4531e86 gactiongroupexporter: Validate actions activated or changed over D-Bus
The action name, parameter and new state are all controlled by an
external process, so can’t be trusted. Ensure they are validated before
being passed to functions which assert that they are correctly typed and
extant.

Add unit tests.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
5fd101eccc tests: Move a helper function around in the actions test
This will be used in an upcoming commit.

This introduces no functional changes.

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

Helps: #1904
2022-12-09 10:45:21 +00:00
Philip Withnall
ab68165a1f Merge branch 'fix-msvc-test-postprocessing' into 'main'
ci: Don’t fail if testlog-unstable_tests.junit.xml doesn’t exist on MSVC

See merge request GNOME/glib!3115
2022-12-09 10:07:36 +00:00
Philip Withnall
fc6db764cb gtestutils: Use backslashes for isolated test dirs on Windows
Using `test_run_name` in the path for the isolated dir tree for a test
is fine on Unix, because the `/` separator from GTest paths is suitable
as a file system separator.

On Windows, however, it doesn‘t work when mixed and concatenated with
paths which use backslashes. In particular, byte-by-byte path
comparisons don’t work. There are likely also issues if running on a
system with non-UTF-8 file system encoding.

Fix that by storing a file system path version of `test_run_name`
separately, and using the correct `G_DIR_SEPARATOR` for the host OS.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 18:03:01 +00:00
Philip Withnall
42e810e2c1 ci: Don’t fail if testlog-unstable_tests.junit.xml doesn’t exist on MSVC
That file is created if running the `unstable_tests` suite succeeds. It
can fail, though, leaving that log file nonexistent. There’s no point in
failing the whole test run by bailing out if postprocessing the log file
fails.

Occasionally postprocessing can fail with a `FileNotFoundError`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 15:27:24 +00:00
Philip Withnall
c27b02ace7 Merge branch 'gio-thumbnail-sizes' into 'main'
file-info: Add a set of attributes for large thumbnails

Closes #621

See merge request GNOME/glib!2918
2022-12-08 09:04:45 +00:00
Matthias Clasen
f0606d5421 file-info: Add a set of attributes for large thumbnails
Some applications (eg., gnome-photos) really want a large thumbnail,
if one can be created. Simply falling back to a smaller one (probably
created by an old nautilus), without giving the application a chance
to create a bigger thumbnail, is undesirable because they will appear
fuzzy.

Therefore, at separate attribute sets for all the thumbnail sizes
that are supported in the spec: normal/large/x-large/xx-large.

The old attribute will now return by default the biggest available, as
it used to be, but also including the x-large and xx-large cases.

Co-Authored-by: Marco Trevisan <mail@3v1n0.net>

Fixes: #621
2022-12-08 05:21:19 +01:00
Philip Withnall
ddae990509 docs: Remove a stray > in the glib-mkenums man page
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-07 08:17:17 +00:00
Philip Withnall
bbb3453c82 Merge branch 'atomic-unref-cleanups' into 'main'
gobject: Use compare and exchange full to re-read old ref value

See merge request GNOME/glib!3098
2022-12-06 16:12:59 +00:00
Philip Withnall
00bac74bdd Merge branch 'main' into 'main'
gsimpleproxyresolver: Make explicit that a port is needed for HTTP/HTTPS

See merge request GNOME/glib!3100
2022-12-06 13:37:47 +00:00
Chris Talbot
eb12afed6f gsimpleproxyresolver: Make explicit that a port is needed for HTTP/HTTPS 2022-12-06 13:37:47 +00:00
Philip Withnall
2ca08bde4f Merge branch 'gwakeup-cleanups' into 'main'
gwakeuptest: Do not rely on alarm() to stop tests on timeout

See merge request GNOME/glib!3108
2022-12-06 13:16:35 +00:00
Marco Trevisan
49a7762ec0 Merge branch 'iochannel-buf-size' into 'main'
giochannel: Clarify assertions in g_io_channel_write_chars()

See merge request GNOME/glib!3079
2022-12-06 11:38:29 +00:00
Marco Trevisan (Treviño)
94b658ab4c gwakeup: Be consistent in reading the same data we wrote
During acknowledge read the same quantity we wrote (and expected by eventfd)
instead of always reading just 16 bytes.
2022-12-06 12:28:11 +01:00
Marco Trevisan (Treviño)
345e5bcf2c gwakeuptest: Do not rely on alarm() to stop tests on timeout
We have meson nowadays, so tests are timing out by default and test timeout
may vary depending on the meson test parameters or test setups.

So don't hardcode it using alarm().
2022-12-06 12:25:22 +01:00
Philip Withnall
720a1147a6 Merge branch 'object-refcount-checks' into 'main'
gobject: Check for valid ref counting via g_return_if_fail

See merge request GNOME/glib!3106
2022-12-06 09:04:03 +00:00
Marco Trevisan (Treviño)
6cd6cc41bb gobject: Trace unref just after this happened
Trace the unref before potentially calling (user) code that may re-ref
or unref again, causing the tracing order to be messed up.
2022-12-06 04:43:02 +01:00
Marco Trevisan (Treviño)
0918ce013a gobject: Do not call toggle down notifications if current refcount is not 1
When an object is revitalized and a notify callbacks increased the reference
counter of the object, we are calling the toggle notifier twice, while it
should only happen if also the actual reference count value is 1 (after
having been decremented from 2).
2022-12-06 04:38:26 +01:00
Marco Trevisan (Treviño)
1f852863ec gobject: Check for toggle references only if the old ref is relevant
If an object gets revitalized during the dispose vfunc, we need to call
toggle refs notifiers only if we had 2 references and if the object has
the toggle references enabled.

This may change in case an object notifier handler changes this status,
so do this check only after we've called the notifiers so that in case
toggle notifications are enabled afterwards we still call the handlers.
2022-12-06 04:28:31 +01:00
Marco Trevisan (Treviño)
5e2b288033 gobject/tests/reference: Add test for notify during dispose
We need to check whether notifications and toggle references are working
properly if an object gets revitalized during the dispose vfunc.
2022-12-06 04:28:31 +01:00
Marco Trevisan (Treviño)
ea0c4d45b2 gobject/tests/reference: Add test for toggle reference up/down during dispose 2022-12-06 03:32:51 +01:00
Marco Trevisan
6599cf95ae Merge branch 'wip/pwithnall/dbus-system-bus-address' into 'main'
gdbusaddress: Use runstatedir rather than localstatedir

See merge request GNOME/glib!3101
2022-12-06 00:24:17 +00:00
Marco Trevisan (Treviño)
c0360f626c gobject: Read the toggle reference state only after we've update the references
We were reading if an object has toggle references even if this was not
really relevant for the current object state, as we only need to notify
when going from 2 to 1 references, so first ensure that this is the case
and then check if we have toggle references enabled in the object.

This is a micro-optimization, for the way flags are defined, but still
an operation we can avoid in most cases.
2022-12-06 01:22:34 +01:00
Marco Trevisan (Treviño)
30e1d69de7 gobject: Check for valid ref counting via g_return_if_fail
Even though the check is likely to be relevant if the object is finalized,
it may still give some indication if called while an instance has just lost
the last reference.

So use `g_return_if_fail` for consistency with the rest of the code.
2022-12-05 20:23:26 +01:00