Commit Graph

8308 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
51c023f189 tests/codegen: Add checks for signal emission enums
These are checked to be correct by code compilation, but let's ensure we
also have some kind of forma check on the expected syntax.
2023-06-30 22:17:46 +02:00
Marco Trevisan (Treviño)
4b05e06e1c gdbus-codegen: Address more black cleanups 2023-06-30 22:17:46 +02:00
Marco Trevisan (Treviño)
1b345e411f meson: Add all the gdbus-codegen based tests to the proper suite
So it's easier to run them all with --suite=gdbus-codegen
2023-06-30 18:11:18 +02:00
Luca Bacci
2dc0a43bc0 glocalfileinfo: Fix GLocalFileStat getters on MinGW x86
For some reason, `time_t` is defined as being 32 bits wide on that
platform, which causes truncation of the timestamps from `struct stat`.

Avoid that problem by consistently using a 64-bit return value from the
`struct stat` accessors.

Helps: #3039
2023-06-30 15:00:56 +01:00
Marco Trevisan (Treviño)
88d48a7a22 codegen: Use g_signal_emit to emit signals
We were using emit_by_name which implies looking up for the signal name,
while the generated code can easily remember the signal ID and use it
instead, allowing direct access to the signal emission.
2023-06-29 22:20:05 +02:00
Philip Withnall
9845f880ca glocalfileinfo: Delete some redundant code
`_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_ATIME)` will always
return `TRUE` on Windows (since it uses a basic `struct stat`), so the
platform-inspecific code is equivalent to the Windows-specific code.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-28 17:49:45 +01:00
Philip Withnall
c3762deb78 glocalfileinfo: Fix incorrect use of struct statx.st_mtimensec on Android
`GLocalFileStat` is a platform-specific abstraction around `struct stat`
or `struct statx`. If `struct statx` is available, it will use that by
preference as it has more features.

`glocalfileinfo.c` was, in some places, incorrectly accessing the fields
of `GLocalFileStat` directly rather than through its `_g_stat_*()`
getters. While it correctly accounted for the platform-specific
differences between `st_mtimensec` and `st_mtim.tv_nsec`, it hadn’t been
updated to deal with `stx_mtime`.

On Android, `st_mtimensec` is defined as a fallback for
`st_mtim.tv_nsec` (even though it doesn’t need to be). This caused GLib
to take the `st_mtimensec` code path rather than the `stx_mtime` code
path, and hence try to dereference `st_mtim` in a `struct statx`.

Fix that by correctly using the `_g_stat_*()` getters consistently.

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

Fixes: #3039
2023-06-28 17:32:25 +01:00
Philip Withnall
989b4cb8bd gapplication: Tweak option group description
To match the documented style for all option group descriptions.

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

Helps: #3007
2023-06-28 17:04:59 +01:00
Ondrej Holy
c083a4d1a6 gio-tool-mount: Add option to show progress when unmounting 2023-06-28 15:51:51 +00:00
N.Pranav Krishna
b963bcf8c5 Added Annotations 2023-06-27 16:49:43 +00:00
Christian Hergert
d972ba03b4 listmodel: add documentation about unique instances
This has subtly been required and the original intention, so make it more
discoverable by adding to the documentation.

Fixes #3030
2023-06-21 11:01:52 -07:00
Matthias Clasen
4171fba2fe gapplication: Clarify docs
D-Bus does not support maybe types, therefore
using such types are action parameters in
GApplication does not work.

Fixes: #3027
2023-06-10 08:04:49 -04:00
Philip Withnall
8cad32a118 Revert "tests: Temporarily disable socket test due to a kernel bug"
This reverts commit 1507585869.

This should now be fixed:
https://gitlab.gnome.org/Infrastructure/Infrastructure/-/issues/981#note_1760399.

Fixes: #2879
2023-06-07 12:29:03 +01:00
Maximiliano Sandoval R
389398d444
resolver: Add space in documentations
It is standard practice to put a space in between Returns and Since in docstrings.
2023-06-04 17:33:00 +02:00
Philip Withnall
fbc66b834e Merge branch 'mcatanzaro/#2829' into 'main'
Improve depfile generated by glib-compile-resources

Closes #2829

See merge request GNOME/glib!3460
2023-06-01 09:36:15 +00:00
Michael Catanzaro
3e3a0304f7 Improve depfile generated by glib-compile-resources
glib-compile-resources --dependency-file= currently generates a depfile
with rules that look like this:

foo.xml: resource1 resource2

This means that if any of the files listed in the GResource manifest
foo.xml change, rebuild foo.xml because foo.xml depends on those files.
This is not useful because the XML manifest is not expected to be a
generated dependency and even if it was, changes to the listed files
would not imply any need to regenerate the manifest. What we really do
need to regenerate is the C source file that is generated by
glib-compile-resources after processing the XML manifest and all the
resource files. That is, the rule should look like this:

foo.c: foo.xml resource1 resource2

as suggested by Hans Ulrich Niedermann in the issue report.

Fixes #2829
2023-05-31 14:50:21 -05:00
Jason Francis
c556a4d8f8
gfileinfo: add (type filename) annotation to symlink_target functions 2023-05-31 00:54:38 -04:00
Michael Catanzaro
cc5bb80b9a Fix failure to respect default port of proxy URLs
Currently we require explicitly specifying the port when configuring a
proxy server, which is seriously weird. I take the fact that nobody
reported a bug until 2022 to indicate that almost nobody is using
proxies. Whatever. Let's assume that if no port is provided, the default
port for the protocol should be used instead.

For example, you can now specify in GNOME settings that your proxy server
is https://example.com and it will work. Previously, you had to write
https://example.com:443. Yuck!

This was originally reported as GProxyResolver bug, but nothing is
actually wrong there. It's actually GProxyAddressEnumerator that gets
tripped up by URLs returned by GProxyResolver without a default port.
This breaks GSocketClient.

Fixing this requires exposing GUri's _default_scheme_port() function to
GIO. I considered copy/pasting it since it's not very much code, but I
figure the private call mechanism is probably not too expensive, and I
don't like code duplication.

Fixes #2832
2023-05-30 09:49:43 -05:00
Philip Withnall
1aefcf4e0e Merge branch 'ok/termux-build-issues' into 'main'
gio, tests: adaptations for building with bionic libc from termux

Closes #3008

See merge request GNOME/glib!3443
2023-05-30 13:04:17 +00:00
Philip Withnall
ad464d5563 Merge branch 'main' into 'main'
gio/tests/portal-support: Fix snap test ordering race

Closes #3020

See merge request GNOME/glib!3454
2023-05-30 12:29:06 +00:00
Philip Withnall
0196a36022 Merge branch 'more-atomic-exchange-full' into 'main'
gdataset, gobject: Use atomic compare and exchange full to set pointers

See merge request GNOME/glib!3426
2023-05-30 11:59:40 +00:00
Marco Trevisan (Treviño)
ea904fba1a gresource: Use compare and exchange full to get registered resources 2023-05-30 12:34:41 +01:00
Philip Withnall
28f83c9cf7 gresource: Ensure lazy_register_resources is always accessed atomically
On some platforms, pointer-sized reads are not necessarily atomic, so we
always need to use the correct atomic access primitives.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 12:33:48 +01:00
Richard Purdie
c63cf19d9a gio/tests/portal-support: Fix snap test ordering race
When the gnome test runner executes the tests, the test appear to execute in disk
order. This means it sometimes works and sometimes we see breakage in portal-support-snap
and portal-support-snap-classic.

The issue is that some tests create config files but some don't. If they run
in the wrong order, tests see config files they shouldn't and break.

Fix this by deleting the files after each test run, properly cleaning up after
themselves. The cleanup code is based upon gtestutils.c:rm_rf().

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-05-30 12:28:45 +01:00
Guido Günther
b3b23072f3 gactionmap: Add g_action_map_remove_action_entries()
Since we have a convenience method to add actions let's allow to remove
them just as easily. This makes resource cleanup as simple as initially
adding the entries.
2023-05-26 10:30:40 +01:00
Guido Günther
ac840b954f gactionmap: Move declaration of loop var in g_action_map_add_action_entries() 2023-05-25 17:45:17 +02:00
Guido Günther
596fec811d gactionmap: Check for < 0 in g_action_map_add_action_entries()
Assume that all negative values mean `NULL` terminated. Everything else
will cause a disaster anyway.
2023-05-25 17:43:09 +02:00
Philip Withnall
ecbe360a38 Merge branch '3003-glib-compile-schemas-failed' into 'main'
glib-compile-resources: Fix non-ASCII arg parsing on Windows

Closes #3003

See merge request GNOME/glib!3446
2023-05-23 17:16:27 +00:00
Daniyar Tleulin
49537e298c glib-compile-schemas: Fix non-ASCII arg parsing on Windows
When the source directory contains non-ASCII symbols,
argument parsing previously failed on MINGW64.

Fixes: #3003
2023-05-23 16:49:21 +06:00
Daniyar Tleulin
0305d237dd glib-compile-resources: Fix non-ASCII arg parsing on Windows
When the source directory contains non-ASCII symbols,
argument parsing previously failed on MINGW64.

Fixes: #3003
2023-05-23 16:48:41 +06:00
Sonny Piers
0b73d72a44 gio: Add g_file_new_build_filenamev 2023-05-23 10:14:28 +00:00
Øyvind Kolås
786f379d78 gio/tests: avoid shadowing of libc names under bionic libc
Makes the tests compile using clang with meson directly under
termux on android, this build environment does not approve of
overloading libc symbols.

Fixes: #3008

foo
2023-05-22 22:44:52 +02:00
Øyvind Kolås
3050c16aea gio: define hasmntopt ourselves under bionic libc
This is a workaround for build conditions one ends up with under termux,
where the defined __ANDROID_API__ level is lower than what is provided
by gcc installed for it, the libc .so nevertheless contains these symbols
thus enabling the codepaths. This definition is only in use when meson
detected the presence of this symbol in the libc.

Fixes #3008

foo
2023-05-22 22:44:52 +02:00
Carlos Garnacho
4641b02ca2 gio: Add test for local enumerator cancellation
Check that the enumerator is able to cancel if told so.
2023-05-19 11:53:18 +00:00
Carlos Garnacho
99571c42d5 gio: Check cancellable iterating local file enumerator
In the typical `while (g_file_enumerator_next_file ())` patterns,
there is nothing much checking whether the operation was cancelled
on the GIO side. Unless the user checks for the case, this means
local enumerators always run to completion even if cancelled.

Fix this by checking the cancellable state explicitly for local
enumerators, so there are oportunities for bailing out early if
the enumerator is going through a very large directory.
2023-05-19 11:53:18 +00:00
Thomas Haller
cdda194844 gmain: remove unnecessary initialization of *timeout in prepare() callbacks
Note that the prepare callback only has one caller, which pre-initializes
the timeout argument to -1. That may be an implementation detail and not
publicly promised, but it wouldn't make sense to do it any other way in
the caller.

Also, note that g_unix_signal_watch_prepare() and the UNIX branch of
g_child_watch_prepare() already relied on that.
2023-05-18 11:26:33 +02:00
Emmanuele Bassi
20142de034 Ignore g_task_print_alive_task() when introspecting GIO
The `__GTK_DOC_IGNORE__` check is not enough for g-ir-scanner: we need
to check for `__GI_SCANNER__` as well.
2023-05-16 13:33:19 +01:00
Philip Withnall
e02fa2ec90 gfile: Ensure loff_t is defined on FreeBSD
When `copy_file_range()` support was added, I used the definition of
`copy_file_range()` from Linux, which uses `loff_t` to abstract the
different `off*_t` types.

`loff_t` doesn’t exist on FreeBSD, so this doesn’t compile, and was
caught in subsequent asynchronous CI.

Define `loff_t` with a fallback value if it’s not defined, which should
fix this and other uses of `loff_t` in `gfile.c` (for example, if
FreeBSD ever starts declaring `splice()`).

Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/2812302

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-15 16:22:35 +01:00
Philip Withnall
8a68b795c1 tests: Fix GIO file size tests as .desktop files have changed size
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-10 09:26:47 +01:00
Arnaud Rebillout
f722f11e57 Rename GTK+ to GTK (mostly comments and documentation)
GTK lost it's '+' suffix back in 2019, according to
<https://mail.gnome.org/archives/gtk-devel-list/2019-February/msg00000.html>

This commit can be re-generated with:

    git grep -l GTK+ \
    | grep -v -e ^NEWS -e ^glib/tests/collate.c \
    | xargs sed -i 's/GTK+/GTK/g'

Most of the changes are in comments and documentation.
2023-05-10 10:56:44 +07:00
Philip Withnall
0e5d9fd249 gfile: Support copy_file_range() for file copies
While it can’t be used in all situations, it is a little bit faster than
`splice()` in some situations, basically if the file system supports
copy on write. In other situations it’s no slower than `splice()`.

See `man copy_file_range` for the situations where it doesn’t work. In
all of these situations, it will return an error, and the GLib code will
fall through and try the existing `splice()` copy code instead.

From my testing of `time gio copy A B` with a 9GB file, the `splice()`
code path takes 22s, and the `copy_file_range()` code path takes 20s.

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

Fixes: #2863
2023-05-09 14:01:50 +01:00
Philip Withnall
aafa19fc0d tests: Add a test for progress callbacks from g_file_copy()
This wasn’t previously tested.

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

Helps: #2863
2023-05-09 14:01:48 +01:00
Philip Withnall
0da948a5d1 gfile: Eliminate a stat() call from the file copy code
The start of the `g_file_copy()` implementation stats the source file to
find all the attributes to copy onto the destination file, so it makes
sense to get it to store the source file size at the same time.

This saves a subsequent `stat()` call on the source FD in the btrfs
reflink or splice code. Every little helps.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-09 13:53:44 +01:00
Philip Withnall
63e1e83c33 Merge branch 'wip/p3732/timeout-seconds-once' into 'main'
add g_timeout_add_seconds_once

See merge request GNOME/glib!3383
2023-05-09 12:50:39 +00:00
Philip Withnall
e59e8ebf31 gwin32networkmonitor: Fix returning address of local variable
Something has changed recently which causes this error to now be emitted
when building on Windows msys2-mingw32:
```
../gio/gwin32networkmonitor.c: In function 'win_network_monitor_get_ip_info':
../gio/gwin32networkmonitor.c:92:15: error: storing the address of local variable 'prefix' in '*dest' [-Werror=dangling-pointer=]
   92 |         *dest = (guint8 *) &prefix.Prefix.Ipv4.sin_addr;
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

If `IP_ADDRESS_PREFIX` is defined as a scalar rather than a pointer,
that could explain the problem.

Change the function to always operate on a pointer to avoid any
potential such issues.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-09 12:52:42 +01:00
Peter Eisenmann
e25a4f995f use g_timeout_add_seconds_once()
Use the newly added g_timeout_add_seconds_once() where appropriate.
2023-05-02 13:42:54 +02:00
Philip Withnall
1f044e1cbd Merge branch '2855-test-socket-rename' into 'main'
Rename confusing socket test filenames

Closes #2855

See merge request GNOME/glib!3415
2023-05-02 09:38:25 +00:00
Mike Salmela
dea11643a9 Rename confusing socket test filenames
The gio/tests/socket-client.c doesn't use GSocketClient, which makes the
filename confusing. What the file actually tests is the GSocket. Rename
it to socket-testclient.c
The corresponding GSocket server test file naming doesn't conflict with other
class names, but rename it to socket-testserver.c for consistency.

Closes #2855
2023-04-29 21:48:03 +03:00
Philip Withnall
b38ddf5087 gregistrysettingsbackend: Remove translatable pspec nick/blurb
The file was not listed in `POTFILES.in` (as pointed out by Piotr Drąg
in
fee0a7679a (note_1722885)),
so either it needs to be added to `POTFILES.in` or the translatable
strings need to be removed.

Recent prior art from GTK shows that there’s actually no longer any
point in setting the nick/blurb as no tools use them (and if they did,
it would result in a rubbish user experience). See
https://gitlab.gnome.org/GNOME/gtk/-/issues/4904.

Hence, drop the strings entirely.

See #2991 for tracking this across all of GIO.

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

Helps: #2991
2023-04-27 23:33:47 +01:00
Philip Withnall
865cbe3714 gthreadedresolver: Remove some incorrect assertions
If a timeout executes on the same main context iteration as completion
or cancellation of a resolver lookup, `has_returned` will be set
multiple times. That’s fine (the `GCond` will be notified multiple
times, but that’s fine). It was triggering an incorrect assertion, so
remove that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 14:41:26 +01:00
Philip Withnall
7922d3200c Merge branch 'resolver-thread-pool' into 'main'
gthreadedresolver: Switch to using a separate thread pool and support timeouts

See merge request GNOME/glib!3397
2023-04-27 12:46:53 +00:00
Philip Withnall
6c1cbdff63 Merge branch 'task-tracking' into 'main'
gtask: Track pending GTasks if G_ENABLE_DEBUG is defined

See merge request GNOME/glib!3404
2023-04-27 12:46:37 +00:00
Philip Withnall
d231ce0364 Merge branch '2951-reinstate-fileinfo-criticals' into 'main'
Revert "gfileinfo: Temporarily downgrade missing attribute criticals to debugs"

Closes #2951

See merge request GNOME/glib!3379
2023-04-27 11:27:43 +00:00
Philip Withnall
e73c5ed5e1 gresolver: Set timeout on default resolver to 30s
The default for the class is still to have no timeout, but it seems more
practical for most use cases to set a non-infinite timeout on the
default resolver.

If applications have a more specific use case, they can change the
timeout or replace the default resolver.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3397#note_1731387

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
1c4384aec5 tests: Fix cancellation source handling in resolver manual test
If `async_cancel()` was invoked, it would remove the IO watch source,
which would cause the `g_source_remove()` call at the end of `main()` to
warn about an unknown source ID.

Fix that by handling the source as a pointer instead of a handle.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
2ac66413a4 tests: Support --timeout argument in resolver manual test
For testing timeouts.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
ef08e8dd81 gthreadedresolver: Document design of GThreadedResolver
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
c3209f1d84 gthreadedresolver: Re-add cancellation and add timeout support
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
7b18e6205a gthreadedresolver: Switch to using a separate thread pool
Rather than running lookups in the global shared thread pool belonging
to `GTask`, run them in a private thread pool.

This is needed because the global shared thread pool is constrained to
only 14 threads. If there are 14 ongoing calls to
`g_task_run_in_thread()` from any library/code in the process, and then
one of them asks to do a DNS lookup, the lookup will block forever.

Under certain circumstances, particularly where there are a couple of
deep chains of dependent tasks running with `g_task_run_in_thread()`,
this can livelock the program.

Since `GResolver` is likely to be called as a frequent leaf call in
certain workloads, and in particular there are likely to be several
lookups requested at the same time, it makes sense to move resolver
lookups to a private thread pool.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
84074ce757 gthreadedresolver: Centralise GTask return handling in worker threads
This will make it simpler to handle timeouts and cancellation in future,
as all the logic for working out whether to return will all be in one
place, and all the lookup-specific code is now implemented in simple
sync functions which don’t need to care about `GTask`s.

This commit introduces no functional changes, it’s just setting up for
the following commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
694394207c gthreadedresolver: Combine closure structs for different lookup types
This introduces no functional changes, but will make a reorganisation of
the code simpler in the next commit.

Rather than dealing with three different closure types, this changes the
code to deal with one which is a tagged union of the three.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
6e499764e4 gthreadedresolver: Port to G_DECLARE_FINAL_TYPE
The class and its header are not public, so this should not be an API or
ABI break.

This just simplifies the code a little and allows for easy extension of
the object’s private data in future commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:23:25 +01:00
Philip Withnall
bf92bae481 gresolver: Add GResolver:timeout property
Without a timeout, some lookup requests can go on forever, typically due
to bugs in underlying systems.

This can have particularly significant effects on the Happy Eyeballs
algorithm in `GSocketClient`, which relies on multiple name lookups as
its first step.

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

Helps: #2866
2023-04-27 12:23:25 +01:00
Philip Withnall
06eecda823 gtask: Track pending GTasks if G_ENABLE_DEBUG is defined
Track the `GTask`s which are still alive (not finalised) in a shared
list, and provide a secret debugging function for printing that list.

Too often when debugging apps, I have found that a ‘leaked’ object is
actually still (validly) referenced by an ongoing `GTask` which hasn’t
completed for whatever reason. Or I have found that an operation has
obviously stalled, but there are no pointers available to the `GTask`
which is stalled, because it’s being tracked as a collection of closure
pointers from some `GSource` which is hard to get to in the debugger.

It will be very useful for debugging apps, if there’s a list of all the
still alive `GTask`s somewhere. This is that list.

The code is disabled if `G_ENABLE_DEBUG` is not defined, to avoid every
`GTask` construction/finalisation imposing a global locking penalty.

To use the new list, break in `gdb` while running your app, and call
`g_task_print_alive_tasks()`, or inspect the `task_list` manually:
```
(gdb) print g_task_print_alive_tasks()
16:44:17:788 GLib-GIO 5 GTasks still alive:
 • GTask 0x6100000ac740, gs_plugin_appstream_setup_async, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x6100000bf940, [gio] D-Bus read, ref count: 2, ever_returned: 0, completed: 0
 • GTask 0x6100000aac40, gs_plugin_loader_setup_async, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x61000006d940, gs_plugin_loader_job_process_async GsPluginJobRefine, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x610000118c40, [gio] D-Bus read, ref count: 2, ever_returned: 0, completed: 0
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:22:05 +01:00
Philip Withnall
8d527919b4 Merge branch 'update-errfmt-in-gunixconnection-part3' into 'main'
restore error messages in gunixconnection while maintaining older compiler support

See merge request GNOME/glib!3400
2023-04-26 16:27:34 +00:00
James Knight
55e93a8278 gio: switch gunixconnection ngettext with g_dngettext calls
This commit changes the use of `ngettext` with `g_dngettext`. The
project defined `g_dngettext` (with domain support) provides the same
functionality as `ngettext` with a NULL domain provided. The purpose of
this change is to help address a build error for certain compilers that
trigger a `format-nonliteral` error-promoted-warning when using
`ngettext` (see also [1][2]). The benefit of switching to use
`g_dngettext` is that the function is defined with `G_GNUC_FORMAT`. This
provides a hint to GNU GCC compilers to still sanity check these
arguments, but not generate a `format-nonliteral`.

[1]: 4ae8606b6f
[2]: 0ca660315a

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-25 23:25:38 -04:00
James Knight
0ca660315a Revert "Fix error format in gio/gunixconnection.c (part 2)"
This reverts commit 4ae8606b6f. The idea
for the change [1] was to address a build error for certain compilers
that trigger a `format-nonliteral` error-promoted-warning since these
compilers do not gracefully support `ngettext` usage. The changes
following a pattern from an old commit [2]; however, James Hilliard has
pointed out these changes do not work as intended. A deeper inspection
of the commit showed that the commit was from an old merge request that
was not pulled in, detailing why the changes did not work (see also
[3][4]).

Manipulating the sockets unit test confirms that the format values no
longer get a proper value:

    ...
    ok 9 /socket/address
    ok 10 /socket/unix-from-fd
    ok 11 /socket/unix-connection
    **
    GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting one fd, but got %d
     (g-io-error-quark, 0)
    ...

And reverting this change restores the original functionality:

    ...
    ok 9 /socket/address
    ok 10 /socket/unix-from-fd
    ok 11 /socket/unix-connection
    **
    GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting 1 control message, got 0 (g-io-error-quark, 0)
    ...

[1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3390
[2]: 44b3d5d80445234041f6c59feb89645f7102c3a4
[3]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/770
[4]: https://gitlab.gnome.org/GNOME/glib/-/issues/1744

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-25 23:21:58 -04:00
Philip Withnall
c256af1c2d gthreadedresolver: Add some additional debug prints
These make it a bit easier to track the ongoing resolver tasks, as the
tasks and/or their closures are not tracked in a big list somewhere.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-25 15:35:54 +01:00
Philip Withnall
885eb1d8e5 gtask: Document that g_task_run_in_thread() uses a shared resource
It’s a bad idea to use it without some care for how much it’s being
called in parallel, or dependencies between tasks. If the thread pool
gets exhausted by too many inter-dependent calls to
`g_task_run_in_thread()` then the process will livelock.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-25 15:29:55 +01:00
Marco Trevisan
9308f2c353 Merge branch 'wip/3v1n0/gio-gmodule-visibility-dep' into 'main'
gmodule: Define a gmodule include dependency and use it in gio modules

Closes #2982

See merge request GNOME/glib!3386
2023-04-21 13:58:50 +00:00
James Knight
4ae8606b6f Fix error format in gio/gunixconnection.c (part 2)
Update a series of error messages to use `g_set_error_literal` instead
of `g_set_error`. This should prevent `format-nonliteral` compiler
issues when `-Werror` is configured:

    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_fd’:
    ../gio/gunixconnection.c:183:9: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      183 |         nscm);
          |         ^~~~
    ../gio/gunixconnection.c:217:20: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      217 |                    nfd);
          |                    ^~~
    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_credentials’:
    ../gio/gunixconnection.c:601:24: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      601 |                        nscm);
          |                        ^~~~

This is similar to a previous change [1] made to `gunixconnection.c`.

[1]: 44b3d5d80445234041f6c59feb89645f7102c3a4

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-20 23:41:32 -04:00
Emmanuele Bassi
b8466bb54d Merge branch 'wip/3v1n0/macos-add-desktop-app-info' into 'main'
appmonitor: Skip the test under OSX

See merge request GNOME/glib!3388
2023-04-20 16:52:45 +00:00
Marco Trevisan (Treviño)
d296e94559 appmonitor: Skip the test under OSX
Since commit c0ca3f99 this test is strictly depending on GDesktopAppInfo
that is not defined or available in macos, so skip the test as we do for
windows.

We could have done this at meson level too, but keeping it this way is
probably a better reminder that this should be adapted for such scenario
one day™

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2753753
2023-04-20 16:37:32 +02:00
Marco Trevisan
9f3c4ec940 Merge branch 'old-mac-sdk' into 'main'
gio: fix build on older macOS SDKs

See merge request GNOME/glib!3385
2023-04-20 13:12:06 +00:00
Peter Williams
bb19523a0a gio: fix build on older macOS SDKs
The merge request !2848 added code to automatically detect the module
prefix on macOS, with a test for the Mac #define TARGET_OS_OSX. However,
older versions of the SDK (at least 10.11) don't provide this #define,
leading to build failure. If the #define is missing, fall back to
checking TARGET_OS_MAC. On newer SDKs this symbol is also true for
watchOS, etc., but in those situations TARGET_OS_OSX is available.
2023-04-20 08:54:23 -04:00
Marco Trevisan
aa72638301 Merge branch 'fix-gsocket-receive-from-annotation' into 'main'
gsocket: Explicitly mark size parameter as (in)

See merge request GNOME/glib!3382
2023-04-19 19:19:41 +00:00
Marco Trevisan (Treviño)
fe38a02c62 gmodule: Define a gmodule include dependency and use it in gio modules
Various gio modules include gmodule.h that requires the
gmodule-visibility.h to be already built.

To make this easier, just provide a dependency and use it where we are
building modules that do not depend on libgio_dep (that already includes
that).

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2982
2023-04-19 21:10:29 +02:00
Marco Trevisan
9f111c3416 Merge branch 'valgrind-variable' into 'main'
meson: Add glib_valgrind_suppressions variable to glib pkg-config file

See merge request GNOME/glib!3361
2023-04-17 12:52:28 +00:00
Marco Trevisan (Treviño)
c2e46b3789 meson: cleanup pkg-config variables definitions
Use more readable and shorter syntax
2023-04-17 14:25:52 +02:00
Marco Trevisan (Treviño)
ade79bcb50 meson: Add tests for generated pkg-config files
Ensure things are generated as we expect and avoid we regress on that.
2023-04-17 14:25:52 +02:00
badcel
f510fa0227
gsocket: Explicitly mark size parameter as (in)
The generated gir file marks the size parameter as "out" by default. This is wrong in the context of a caller allocated buffer with a given size. Explicitly marking the size parameter as (in) fixes the issue.
2023-04-15 22:53:05 +02:00
Philip Withnall
da35056247 Merge branch 'registry-settings-root-key' into 'main'
gregistrysettingsbackend: Allow a different root key path

See merge request GNOME/glib!3306
2023-04-14 17:00:01 +00:00
Dario Saccavino
fee0a7679a gregistrysettingsbackend: Allow a different root key path 2023-04-14 17:00:01 +00:00
Philip Withnall
01d5b41afa Revert "gfileinfo: Temporarily downgrade missing attribute criticals to debugs"
This reverts commit 4cad66580b.

Downgrading the criticals was only temporary. Now we’ve branched for
GLib 2.78, the criticals can be reinstated early this cycle, so people
have the maximum time to fix latent bugs in their code.

Fixes: #2951
2023-04-14 17:55:37 +01:00
Philip Withnall
cd118f9af0 Merge branch 'action-group-query-action' into 'main'
actiongroup: Add a compiler warning

See merge request GNOME/glib!3367
2023-04-14 16:32:54 +00:00
Philip Withnall
f2f322005d Merge branch 'update-annotations' into 'main'
Explicitly mark size parameter as (in)

See merge request GNOME/glib!3371
2023-04-14 15:55:38 +00:00
Philip Withnall
58cb296416 Merge branch 'feature/sum_apparent_size_only_for_files_and_symlinks' into 'main'
Align `G_FILE_MEASURE_APPARENT_SIZE` behaviour with `du` from GNU coreutils 9.2

Closes #2965

See merge request GNOME/glib!3358
2023-04-14 15:54:19 +00:00
Philip Withnall
11bdd6fcc4 Merge branch 'wip/jtojnar/wl-are-compiler-flags' into 'main'
build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags

See merge request GNOME/glib!3356
2023-04-14 15:52:56 +00:00
Philip Withnall
088e2a4f5a Merge branch 'socket-nonblock' into 'main'
gsocket/inotify/gwakeup: Use SOCK_NONBLOCK and O_NONBLOCK to avoid fcntl() syscalls where possible

See merge request GNOME/glib!3347
2023-04-14 15:49:52 +00:00
Philip Withnall
1ebfe32c06 Merge branch 'gio-tool-info-strings' into 'main'
gio-tool-info: Fix a duplicate attribute name in the UI

See merge request GNOME/glib!3337
2023-04-14 15:48:43 +00:00
Philip Withnall
5611851eb9 Merge branch 'bsd-libelf-enabled' into 'main'
meson: allow -Dlibelf=enabled without pkg-config

See merge request GNOME/glib!3335
2023-04-14 15:48:20 +00:00
Philip Withnall
56bc6bcad2 Merge branch '1264-gdbus-double-unref' into 'main'
gdbusconnection: Fix double unref on timeout/cancel sending a message

Closes #1264

See merge request GNOME/glib!3291
2023-04-14 14:57:32 +00:00
Philip Withnall
0a84c182e2 gdbusconnection: Improve refcount handling of timeout source
The ref on the timeout source owned by `SendMessageData` was being
dropped just after attaching the source to the main context, leaving it
unowned in that struct. That meant the only ref on the source was held
by the `GMainContext` it was attached to.

This ref was dropped when returning `G_SOURCE_REMOVE` from
`send_message_with_reply_timeout_cb()`. Before that happens,
`send_message_data_deliver_error()` is called, which normally calls
`send_message_with_reply_cleanup()` and destroys the source.

However, if `send_message_data_deliver_error()` is called when the
message has already been delivered, calling
`send_message_with_reply_cleanup()` will be skipped. This leaves the
source pointer in `SendMessageData` dangling, which will cause problems
when `g_source_destroy()` is subsequently called on it.

I’m not sure if it’s possible in practice for this situation to occur,
but the code certainly does nothing to prevent it, and it’s easy enough
to avoid by keeping a strong ref on the source in `SendMessageData`.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
b84ec21f9c gdbusconnection: Rearrange refcount handling of map_method_serial_to_task
It already implicitly held a strong ref on its `GTask` values, but
didn’t have a free function set so that they would be automatically
unreffed on removal from the map.

This meant that the functions handling removals from the map,
`on_worker_closed()` (via `cancel_method_on_close()`) and
`send_message_with_reply_cleanup()` had to call unref once more than
they would otherwise.

In `send_message_with_reply_cleanup()`, this behaviour depended on
whether it was called with `remove == TRUE`. If not, it was `(transfer
none)` not `(transfer full)`. This led to bugs in its callers.

For example, this led to a direct leak in `cancel_method_on_close()`, as
it needed to remove tasks from `map_method_serial_to_task`, but called
`send_message_with_reply_cleanup(remove = FALSE)` and erroneously didn’t
call unref an additional time.

Try and simplify it all by setting a `GDestroyNotify` on
`map_method_serial_to_task`’s values, and making the refcount handling
of `send_message_with_reply_cleanup()` not be conditional on its
arguments.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
08a4387678 gdbusprivate: Use G_SOURCE_REMOVE in a source callback
This is equivalent to the current behaviour, but a little clearer in its
meaning.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
d7c813cf5b gdbusprivate: Improve ownership docs for write_message_async()
The ownership transfers in this code are a bit complex, so adding some
extra documentation and `g_steal_pointer()` calls should hopefully help
clarify things.

This doesn’t introduce any functional changes, just code documentation.

Another drive-by improvement in the quest for #1264.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
861741ef4b gdbusprivate: Ensure data->task is cleared when it returns
The existing comment in the code was correct that `data` is freed when
the task callback is called, because `data` is also pointed to by the
`user_data` for the task, and that’s freed at the end of the callback.

So the existing code was correct to take a copy of `data->task` before
calling `g_task_return_*()`.

After calling `g_task_return_*()`, the existing code unreffed the task
(which is correct), but then didn’t clear the `data->task` pointer,
leaving `data->task` dangling. That could cause a use-after-free or a
double-unref.

Avoid that risk by explicitly clearing `data->task` before calling
`g_task_return_*()`.

After some testing, it turns out this doesn’t actually fix any bugs, but
it’s still a good robustness improvement.

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

Helps: #1264
2023-04-14 15:36:32 +01:00
Emmanuele Bassi
b94d0c2168 Merge branch '799-app-info-monitor-docs' into 'main'
gappinfo: Clarify one-shot behaviour of GAppInfoMonitor::changed in docs

Closes #799

See merge request GNOME/glib!3346
2023-04-13 21:37:36 +00:00
Emmanuele Bassi
18ae2a3d4e Merge branch '322-proxy-subclass-example' into 'main'
tests: Finish update of gdbus-example-proxy-subclass to new GDBus API

Closes #322

See merge request GNOME/glib!3332
2023-04-13 21:35:13 +00:00
badcel
a89b72389a
Explicitly mark size parameter as (in)
The generated gir file marks the size parameter as "out" by default. This is wrong in the context of a caller allocated buffer with a given size. Explicitly marking the size parameter as (in) fixes the issue.
2023-04-11 20:44:06 +02:00
Joan Bruguera
d901b55128 tests/file: Do not rely on du --bytes behaviour
As explained in the previous commit, GNU Coreutils 9.2 changes the behaviour
of `du --bytes` to only count regular files and symlinks.

The previous commit makes the test pass with GNU Coreutils >=9.2, but the
machine running the tests may have an older version, or perhaps even a
reimplementation such as uutils. So we can't rely on the size returned by `du`
to be the consistent across systems any more.

However, the plus side of the new behaviour is that the size reported by `du`
/ `G_FILE_MEASURE_APPARENT_SIZE` is now well-defined across filesystems
(as the sum of the sizes of regular files & symlinks), so we can hardcode it.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2965
2023-04-08 00:39:25 +00:00
Joan Bruguera
011fe5ebb2 glocalfile: Sum apparent size only for files and symlinks
Since GNU Coreutils 9.2 (commit 110bcd28386b1f47a4cd876098acb708fdcbbb25),
`du --apparent-size` (including `du --bytes`) no longer counts all kinds of
files (directories, FIFOs, etc.), but only those for which `st_size` in
`struct stat` is defined by POSIX, namely regular files and symlinks
(and also rarely supported memory objects).

This aligns the behaviour of GLib's `G_FILE_MEASURE_APPARENT_SIZE` flag
with the new GNU Coreutils `du` and correct POSIX use.

Note that this may be a breaking change for some uses.

Link: https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00007.html
Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2965
2023-04-08 00:39:25 +00:00
Dan Yeaw
50851e2706 Fix multiple definition error
Fixes #2966 when compiling with GCC < 9.1 or Clang < 14.0.
2023-04-07 15:22:11 +00:00
Matthias Clasen
e03a96e934 actiongroup: Add a compiler warning
Warn when the boolean return isn't used, since we may not initialize
the out arguments in the FALSE case. Update all internal callers to
use the return value. They were already safe, but users outside GLib
may not be.
2023-04-07 08:44:29 -04:00
Marco Trevisan
9ec6695a72 Merge branch 'drop-gitignore' into 'main'
build: Drop old .gitignore files from test directories

See merge request GNOME/glib!3333
2023-04-05 14:29:13 +00:00
Marco Trevisan
66d9ab7808 Merge branch '2952-pollable-docs' into 'main'
gpollable: Clarify that can_poll() must be called before other methods

Closes #2952

See merge request GNOME/glib!3348
2023-04-05 14:27:07 +00:00
Marco Trevisan
218daa079e Merge branch '2960-debug-controller-docs' into 'main'
gdebugcontrollerdbus: Fix incorrect paragraph on auth in documentation

Closes #2960

See merge request GNOME/glib!3354
2023-04-05 14:24:50 +00:00
Luca Bacci
65e2413dd5 GWin32AppInfo: Fix g_str_has_prefix() check
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2972
2023-04-05 13:50:23 +02:00
Jan Tojnar
004f48f4fc build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags
Previously, `-Wl,--export-dynamic` was in `Libs` key of `gmodule-2.0.pc`,
even though `-Wl` is a compiler flag, rather than a linker one.
This caused issues with API reference builds in evolution-data-server,
which passes the output of `pkg-config --libs` through `--ldflags`
argument of `gtkdoc-scan`, which are forwarded unchanged to `ld`:

    ld: unrecognized option '-Wl,--export-dynamic'

Let’s move the flag to `Cflags` so that the compiler can deal with it.

https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/463
2023-03-31 20:44:14 +02:00
Philip Withnall
224e4e53e2 gdebugcontrollerdbus: Fix incorrect paragraph on auth in documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2960
2023-03-29 14:05:43 +01:00
Philip Withnall
0387c15614 gsocket: Improve wording in a warning message slightly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-23 14:11:36 +00:00
Philip Withnall
5c65437d73 glib-unix: Add O_NONBLOCK support to g_unix_open_pipe()
Add support for it, but don’t use it anywhere yet — this is an API
addition, but currently doesn’t cause any functional changes. It’ll be
used in the next commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-23 14:11:36 +00:00
Philip Withnall
56c013cb6e inotify: Use IN_NONBLOCK to avoid a fcntl() syscall where possible
The `inotify_init1()` API has supported this flag for a long time
(possibly since it was first introduced, although I haven’t bothered
doing the archaeology).

This saves a syscall when first connecting to inotify.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-23 14:11:36 +00:00
Philip Withnall
e2d06873f9 gpollable: Clarify that can_poll() must be called before other methods
Both `GPollableInputStream` and `GPollableOutputStream` are dynamic
interfaces, in that their implementation on a class may only be
functional if certain prerequisites are met at runtime. For example,
a `GConverterInputStream` is only pollable if its base stream is
pollable, and that’s determined at runtime rather than compile time.

As such, both interfaces have a `can_poll()` method. If that method
returns `FALSE`, the behaviour of all other methods on the interface is
undefined.

That was mentioned in the documentation for `can_poll()`, but not any of
the other documentation for the interfaces, which made it a bit hard to
find.

Mention it more widely.

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

Fixes: #2952
2023-03-23 12:08:08 +00:00
Philip Withnall
8b0cf41d88 gsocket: Use SOCK_NONBLOCK to avoid a fcntl() syscall where possible
If the libc and kernel support `SOCK_NONBLOCK`, we can specify that in
the `socket()` flags, and avoid a subsequent call to `fcntl()` to set
`O_NONBLOCK`.

For modern Linux distributions, this will save a syscall when creating a
socket.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-23 01:13:49 +00:00
Philip Withnall
afcd0bb900 tests: Add some explanatory comments to appmonitor test
This should split the code up into logical blocks a bit better, and make
it a bit easier to see what the test is doing at a glance.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
e4546614a8 tests: Port appmonitor test from GMainLoop to using GMainContext directly
This makes the exit conditions for each main loop clearer, and
eliminates use of global variables. It introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
666c72c9c5 tests: Fix non-removal of a timeout in appmonitor test
If the first part of the test takes less than 3s (which is normal), the
timeout for it is not removed, and could spuriously fire during the
second part of the test, causing a false failure.

Instead of relying on source IDs, just use (and explicitly destroy) a
`GSource` for the timeouts.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
c0ca3f995b tests: Fix a FIXME in the appmonitor test
The test thought that calling `g_app_info_get()` was a bit of a hack,
but actually it (or calling another `g_app_info_*()` function) is the
right way to use the `GAppInfoMonitor` API.

See the documentation improvements a couple of commits back for details.

The remaining FIXME higher up in the test should probably be fixed by
getting `g_app_info_monitor_get()` to arm the signal. That requires
changes in `g_app_info_monitor_get()` to call `desktop_file_dir_init()`.
That will have to happen another time.

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

Helps: #799
2023-03-22 15:12:49 +00:00
Philip Withnall
9279f3b0f9 tests: Use g_assert_*() rather than g_assert() in appmonitor tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 14:38:04 +00:00
Philip Withnall
0a10851faa tests: Add copyright/licensing header to appmonitor tests
This is put together through git archaeology:
```
git log gio/tests/appmonitor.c
```

The following commits were too trivial to have meaningful copyright:
 - 54047080e9
 - 4e7d22e268
 - f2c1cfe8c7
 - f8f344923e
 - 3ce00b29ec
 - 3468369625
 - e9d9edde82

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

Helps: #1415
2023-03-22 14:36:57 +00:00
Philip Withnall
c62643adc3 gappinfo: Clarify one-shot behaviour of GAppInfoMonitor::changed in docs
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #799
2023-03-22 14:30:39 +00:00
Philip Withnall
4cad66580b gfileinfo: Temporarily downgrade missing attribute criticals to debugs
This partially reverts ed8e86a7d4.

The change to add the criticals (commit ed8e86a7d4) is correct, but
landed too late in the cycle. Let’s downgrade the criticals to debugs
for now, to stop applications seeing a lot of new criticals in their
output. Those criticals are particularly disruptive for command line
applications and unit tests.

Early in the next cycle, the debugs will be re-upgraded to criticals.
This will give applications a whole additional cycle to fix their
ambiguous use of API.

It turned out that a lot of applications have latent bugs around
calling `g_file_info_get_*()` without checking whether an attribute
is set first, and were hence relying on the ‘unknown’ return value
also being an appropriate default for them.

This was compounded by the fact that several non-local GVFS backends
were not setting `GFileInfo` attributes all the time, which caused the
‘missing attribute’ code path to be hit more frequently. For example,
they would only call `g_file_info_set_is_hidden()` with a true value and
never bother with a false one.

It was further compounded by the fact that, while this change landed for
the 2.75.4 release, there did not seem to be extensive integration
testing of that release, and distributions and downstreams went straight
to 2.76.0. That meant we missed the window between 2.75.4 and 2.76.0 to
change, fix or revert this behaviour. GLib relies on distros and
downstreams doing integration testing of unstable releases. We test with
downstream GNOME as part of gnome-build-meta, but do not have the
resources to do integration testing for everybody.

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

See: #2907
See: #2932
See: #2934
See: #2945
See: #2948
2023-03-21 15:01:10 +00:00
Philip Withnall
2630b7d2d5 Merge branch '352-file-enumerator-docs' into 'main'
gfileenumerator: Clarify termination condition for next_files_async()

Closes #352

See merge request GNOME/glib!3339
2023-03-21 14:58:45 +00:00
Philip Withnall
a046492a19 gfileenumerator: Add an example of using next_files_async() to the docs
This is written in pseudocode C which omits all the callback boilerplate
for the async calls. This should hopefully make the overall structure of
the loop more obvious.

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

Helps: #352
2023-03-21 14:07:08 +00:00
Owen Taylor
67a9367598 gfileenumerator: Clarify termination condition for next_files_async()
As suggested on #352 by Owen Taylor (commit put together by Philip
Withnall, but in Owen’s name as it’s his wording).

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

Fixes: #352
2023-03-21 13:56:52 +00:00
Philip Withnall
2953c08261 gfileinfo: Zero GTimeVal when failing g_file_info_get_modification_time()
Before commit ed8e86a7d4, this function would have silently returned a
zero-valued `GTimeVal` if the correct attributes weren’t present.

That partially regressed in commit ed8e86a7d4, which made it return with
a critical warning, but without zeroing the `GTimeVal`. The critical
warning can be ignored by users (it doesn’t abort the process unless
`G_DEBUG=fatal-criticals` is set), but the change in behaviour of
zeroing the `GTimeVal` could cause bugs.

See: #2907

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-21 12:15:50 +00:00
Philip Withnall
2029d7e900 gpollfilemonitor: Add missing attribute checks for g_file_info_get_size()
Missed from the fixes for #2907.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-21 12:15:50 +00:00
Philip Withnall
4ba3470269 gio: Add some missing file info attribute checks in gio-list and gio-tree
Further fallout from #2907.

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

Fixes: #2948
2023-03-21 12:15:50 +00:00
Philip Withnall
ec03755355 gio-tool-info: Fix a duplicate attribute name in the UI
`gio info` currently prints ‘display name:’ twice. One of those should
be ‘edit name:’ — this regressed in commit
a374b7c806.

Various translations still have the old string, but some unfortunately
do not, so this is effectively a new translatable string again.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-21 11:31:38 +00:00
Jan Beich
f6c40b1d27 meson: allow -Dlibelf=enabled without pkg-config
gio/meson.build:933:0: ERROR: Dependency "libelf" not found, tried pkgconfig
2023-03-20 14:57:36 +00:00
Colin Walters
8d7c1f9b75 tests: Finish update of gdbus-example-proxy-subclass to new GDBus API
This fixes bug #624696.

Incorporates a more recent change from 1dc774a653 to drop the
`g_type_init()` call, and reformats the indentation a bit.

Fixes: #322
2023-03-20 13:03:04 +00:00
Philip Withnall
3d7e88a77d build: Drop old .gitignore files from test directories
They just listed built files. Since the move to Meson, these are all
kept in a separate build directory, not the source tree, so don’t need
to be ignored.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-20 12:09:02 +00:00
Philip Withnall
9d7c796f1e Merge branch 'fix-monitor-root-directory-fail' into 'main'
inotify: Avoid empty root directory string

See merge request GNOME/glib!3241
2023-03-16 12:12:01 +00:00
Philip Withnall
f535d0915f tests: Add a test for creating a file monitor on the root directory
While we can’t check for any events on it, this at least tests that
creating a file monitor works. It should cover the fix from the previous
commit.

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

Helps: !3241
2023-03-15 14:45:10 +00:00
Philip Withnall
1a9be3a1c8 tests: Add a test for D-Bus activating an unknown app with a context
This should catch regressions in the critical warning fixed in the
previous commit.

The launch has to have several conditions:
 - Session bus is running (to avoid the launch happening via the spawn
   codepath)
 - Use a non-existent D-Bus name (to trigger a launch error)
 - Use a launch context (to hit the critical warning code path)
 - Not have a startup ID specified in the platform data — this implies
   having an empty launch context
 - Use an async launch, as that provides an error handling path

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-15 13:50:51 +00:00
Philip Withnall
7cd57b3e85 gdesktopappinfo: Add a missing NULL check
It’s possible for the startup ID to be `NULL` if one wasn’t provided in
the platform data passed to `launch_uris_with_dbus()`.

Passing `NULL` to `g_app_launch_context_launch_failed()` causes a
critical warning.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-14 14:37:14 +00:00
Philip Withnall
764f8426d4 tests: Remove explicit timeout handler from gdbus-auth tests
The timeout runs for the entire duration of the test, which is a
function that Meson’s test harness already provides for us.

Meson’s timeout can be easily adjusted by a factor to allow for running
tests more slowly under valgrind. The timeout in the code cannot, which
leads to spurious failures like
https://gitlab.gnome.org/GNOME/glib/-/jobs/2645271.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-13 11:21:17 +00:00
Philip Withnall
642ee744b8 tests: Fix g_source_remove() of non-existent source in gapplication test
If the timeout callback was executed, it would remove the timeout
source, leaving the `g_source_remove()` call in the main function with a
dangling source ID.

Fixes commit 73205b8bbd.

Spotted in https://gitlab.gnome.org/GNOME/glib/-/jobs/2645271.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-13 11:19:56 +00:00
Luca Bacci
061da06118 GWin32AppInfo: Add NULL string checks
Fixes #2922
2023-03-09 14:29:38 +01:00
Ondrej Holy
1e4a8d3271 Merge branch '2934-false-null-file-attributes' into 'main'
glocalfile: Set various file attributes if their value is FALSE

Closes #2934

See merge request GNOME/glib!3313
2023-03-07 15:33:59 +00:00
Philip Withnall
ff2fad77ef Merge branch 'wip/oholy/lost-and-found-is-hidden' into 'main'
glocalfileinfo: Mark the lost+found dir as hidden again

See merge request GNOME/glib!3310
2023-03-06 17:47:46 +00:00
Philip Withnall
ab3076a242 Merge branch '2932-check-etag-attributes' into 'main'
gfile: Check ETag attribute is present before trying to get it

Closes #2932

See merge request GNOME/glib!3312
2023-03-06 17:42:01 +00:00
Philip Withnall
335d3a4c04 Merge branch 'wip/oholy/is-backup-false' into 'main'
glocalfileinfo: Ensure that is-backup is always set

See merge request GNOME/glib!3311
2023-03-06 17:41:35 +00:00
Philip Withnall
303d79989c gresourcefile: Fix a missing newline in GResourceFile
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-06 16:10:50 +00:00
Philip Withnall
a4e597520a glocalfileinfo: Set is-backup attribute on Windows
Previously it was only being set on non-Windows platforms. For
consistency, always set it on Windows too.

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

Helps: #2934
2023-03-06 16:10:50 +00:00
Philip Withnall
8c473c5353 glocalfile: Set various file attributes if their value is FALSE
Following on from #2907, set various boolean attributes if they have
been requested, or are known for sure, and their value is `FALSE`.

Previously the `FALSE` value would have been implicitly returned by the
getter function, but now doing that without the attribute being
explicitly set will trigger a critical warning.

*Don’t* set these attributes if their value is unknown or there was an
error querying it.

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

Fixes: #2934
2023-03-06 16:10:50 +00:00
Ondrej Holy
c965bf23a8 glocalfileinfo: Set is-backup attribute also on Windows
The `is-backup` attribute isn't currently set on Windows. It would
be nice to set such basic attributes on all platforms. Let's set
the attribute to `FALSE` there.
2023-03-06 14:33:39 +01:00
Ondrej Holy
448a163bee glocalfileinfo: Ensure that is-backup is always set
Currently, the `G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP` attribute is set
only when its value is `TRUE`. This is wrong with the latest changes as
the `GLib-GIO-CRITICAL **: 00:54:07.260: GFileInfo created without
standard::is-backup` errors are printed now from the
`g_file_info_get_is_backup` function among others. Let's set this
aattribute also when it is `FALSE`.

Related: https://gitlab.gnome.org/GNOME/glib/-/issues/2934
2023-03-06 14:33:39 +01:00
Ondrej Holy
43066d6960 glocalfileinfo: Mark the lost+found dir as hidden again
The lost+found dir isn't detected as hidden currently. This is regression
caused by the commit 728ad64b. Let's change the code a bit to be sure that
the lost+found dir is marked as hidden again.
2023-03-06 14:10:13 +01:00