1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2026-10-24 00:49:00 +03:00
Commit Graph

9349 Commits

Author SHA1 Message Date
Sergey Bugaev
75768ba482 gio: Apply property accessor annotations to GDBus types
These properties all have their names prefixed with 'g-', in order to
avoid conflicts with property names coming directly from an actual D-Bus
interface that a derived type might want to install. The corresponding
accessor methods are identified by theit full C symbol name, so their
names are not prefixed.

But this resulted in g-ir-scanner being unable to see the connection
between the properties and their accessors. Help it out with explicit
annotations.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2026-03-30 14:30:04 +03:00
Philip Withnall
a9e4ebd235 Merge branch 'bugaevc/list-store-no-op' into 'main'
liststore: Micro-optimize no-op bulk operations

See merge request GNOME/glib!5099
2026-03-29 16:20:55 +00:00
Philip Withnall
f45819746c Merge branch 'test-dbus-config' into 'main'
gtestdbus: Keep config file around until bus daemon exits

See merge request GNOME/glib!5094
2026-03-29 16:16:20 +00:00
Sergey Bugaev
b9682e7a11 liststore: Micro-optimize no-op bulk operations
If we can see we're not going to be doing anything, bail out early.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2026-03-29 16:26:37 +03:00
Philip Withnall
39400ef06d gtestdbus: Keep config file around until bus daemon exits
Previously, the config file for the mock bus daemon was deleted as soon
as the daemon had started up. That was fine, until when the daemon came
to reload its configuration at runtime, which can happen if (for
example) a new activatable service is added to the service directory
specified in `g_test_dbus_add_service_dir()` at runtime. The daemon
would error and not load the new activatable service config.

Avoid that by keeping the config file around until the daemon exits, and
then deleting it.

Change the deletion code to ignore `ENOENT` (as the config file might
have been cleaned up by the `G_TEST_OPTION_ISOLATE_DIRS` code, or
similar, by then) and to print a warning rather than aborting (like the
`kill()` code above).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-13 12:12:34 +00:00
Philip Withnall
209954d13b Merge branch 'iptosmessage-test-skips' into 'main'
Prevent iptosmessage test failures on FreeBSD and Hurd

See merge request GNOME/glib!5090
2026-03-12 20:40:56 +00:00
Philip Withnall
7142976201 tests: Skip iptosmessage tests on GNU Hurd
It doesn’t support the `IP_RECVTOS` and `IPV6_RECVTCLASS` options
needed by the tests.

Fixes failures like this CI job:
https://gitlab.gnome.org/GNOME/glib/-/jobs/6231522

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-12 20:26:56 +00:00
Philip Withnall
3dc34e9d65 tests: Allow iptosmessage test to fail on FreeBSD
It fails there and I’m not a FreeBSD developer so I cannot debug it.

Filed https://gitlab.gnome.org/GNOME/glib/-/issues/3906 about it.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-11 15:41:56 +00:00
Philip Withnall
49b3dd548c tests: Fix a minor memory leak in the socket test
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-11 15:02:17 +00:00
depuc8
1550cc0c78 gio: Clarify definition of backup files in GFileInfo
The documentation for g_file_info_get_is_backup() and the
G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP attribute did not define
what constitutes a backup file.

Closes #3885
2026-03-11 00:34:10 +05:30
Philip Withnall
dec4005fbc Merge branch 'cm/fix-argument-strings-leaks' into 'main'
gdesktopappinfo: Fix leaks in g_desktop_app_info_launch_uris_with_spawn

Closes #3905

See merge request GNOME/glib!5074
2026-03-09 11:32:54 +00:00
correctmost
2bc433a8aa gdesktopappinfo: Fix leaks in g_desktop_app_info_launch_uris_with_spawn
Previously, argument strings could leak due to an early loop-exit in
g_strfreev because of a NULL array entry.

Closes #3905
2026-03-08 03:47:54 -04:00
correctmost
b31324ecb3 gio-tool-launch: Fix a filename leak
A g_canonicalize_filename call was introduced in c924de69f0, but
a corresponding g_free call was missed.

Fixes: c924de69f0
2026-03-07 23:34:23 -05:00
Michael Catanzaro
e6277acc44 Merge branch '3897-set-symlink' into 'main'
glocalfileinfo: Fix symlink() call so setting symlinks via GFileInfo works

Closes #3897

See merge request GNOME/glib!5043
2026-03-03 10:09:03 -06:00
Philip Withnall
4a1cff9823 Merge branch 'wip/socket-connection-no-remote-address' into 'main'
gsocketconnection: Set an error when closed if no address is cached

See merge request GNOME/glib!5030
2026-02-27 12:12:46 +00:00
Roberto Vidal
d9452bcc50 Minor documentation Markdown/gi-docgen fixes
* Markdown rendering breaks in a few places due to
  unescaped asterisks.
* A few intra-docs references are not being picked by
  gi-docgen.
2026-02-26 14:14:30 +00:00
Philip Withnall
5133805291 glocalfileinfo: Fix symlink() call so setting symlinks via GFileInfo works
It appears that this has been broken from when GIO was merged into GLib,
as the arguments to `symlink()` were the wrong way round.

Add a unit test, and fix the arguments.

Currently the unit test needs to create a symlink on disk first, as GIO
apparently doesn’t support creating symlinks from scratch — only
changing the target of existing ones.

Diagnosed by Michael Catanzaro.

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

Fixes: #3897
2026-02-25 12:14:53 +00:00
Philip Withnall
a91eb3f53b Merge branch 'cm/fix-gsettings-main-leaks' into 'main'
gsettings-tool: Fix leaks when specifying invalid schemas

See merge request GNOME/glib!5041
2026-02-24 22:04:56 +00:00
correctmost
29df3ce593 gsettings-tool: Fix leaks when specifying invalid schemas 2026-02-24 16:09:17 -05:00
correctmost
3646c9ab7f gsettings-tool: Fix leaks when running set commands
With valid values, the set command would leak a GVariant object
from g_variant_parse:

gsettings set org.gnome.desktop.interface enable-animations false

With invalid values, the set command would leak a string from
g_variant_parse_error_print_context:

gsettings set org.gnome.desktop.interface enable-animations foo

The freeme string was unused since commit 8148a3c39.
2026-02-24 15:08:56 -05:00
Marco Trevisan (Treviño)
39409b8161 gthreadedresolver: Fix comparison between signed and unsigned
The comparison was between a gint and guint which could cause issues.
Cast len to guint for the comparison since res_query() can return
values up to the buffer size.
2026-02-23 17:35:24 +01:00
Marco Trevisan (Treviño)
1160332bb5 gio/tests/socket: Use gsize for socket address length
Socket address length should be gsize to match the type expected by
socket APIs, not gint which could cause signedness issues.
2026-02-23 17:35:24 +01:00
Marco Trevisan (Treviño)
77c9c4597b glocalfile: Use size_t for strlen() result
strlen() returns size_t, so using size_t instead of int prevents
potential overflow and signedness issues when iterating over string
length.
2026-02-23 17:35:24 +01:00
Marco Trevisan (Treviño)
bb8a72060b gdocumentportal: Use unsigned int for list length
g_list_length() returns guint, so using unsigned int instead of int
prevents signedness mismatch and potential overflow.
2026-02-23 17:35:24 +01:00
Marco Trevisan (Treviño)
69ea45d78c gsettings: Use size_t for string length and iteration
Using gint for string length and iteration indices could overflow for
paths longer than INT_MAX, though this is unlikely in practice.

Using size_t makes the code consistent with strlen() return type and
prevents potential signedness issues.
2026-02-23 17:35:24 +01:00
Rudi Heitbaum
a9a9906537 Fix const qualifiers where discarded
This patch fixes several const qualifiers by adjusting where required.

Since glibc-2.43 and ISO C23, the functions bsearch, memchr, strchr,
strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr
that return pointers into their input arrays now have definitions as
macros that return a pointer to a const-qualified type when the input
argument is a pointer to a const-qualified type.

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
2026-02-23 11:44:02 +00:00
Jonas Ådahl
0e1b4a735d gsocketconnection: Set an error when closed if no address is cached
g_socket_connection_get_remote_address() has 2.40 been able to get the
remote address for not connected sockets by caching the name when
connecting. However, it never set an error when there was no address
cached. This appears to happen sometimes when trying to print the remote
address of incoming connections of a GSocketService. Fix this by setting
a 'not-connected' error when not connected and there was no address
cached.
2026-02-17 22:55:10 +01:00
Philip Withnall
52668fd796 Merge branch 'fix-gio-speeds' into 'main'
gio-tool-{copy,move}: Fix incorrect transfer rate calculation and improve visualization

See merge request GNOME/glib!4966
2026-02-10 19:17:22 +00:00
Marco Trevisan (Treviño)
6b5b1b478d gio-tool-{copy,move}: Add current speed to progress
Currently we're showing the progress by indicating the average speed
rather than the actual current speed and this could be misleading.

So report both while the transfer is in progress
2026-02-10 19:43:05 +01:00
Marco Trevisan (Treviño)
88813577eb gio-tool-{copy,move}: Fix incorrect transfer rate calculation
The rate calculation divided elapsed time in microseconds by
G_USEC_PER_SEC before dividing bytes by the result. For transfers
completing in under 1 second, this caused the time to truncate to 0,
making MAX() clamp it to 1, resulting in bytes/1. This byte count was
then passed to g_format_size(). So for example in this case:

gio copy -p "/tmp/copy-src" /tmp/copy-dest
Transferred 79,5 kB out of 79,5 kB (79,5 kB/s)

The actual rate should have been "12.2 MB/s" or higher.

Fixed by multiplying bytes by G_USEC_PER_SEC before dividing by
elapsed microseconds, ensuring correct bytes-per-second calculation
for all transfer durations.
2026-02-10 19:41:38 +01:00
Luca Bacci
e08ae7fb7a GApplication: make send_notification / withdraw_notification thread-safe 2026-02-10 15:46:16 +01:00
Luca Bacci
9fbbe47ea5 Merge branch 'win32-notification' into 'main'
gnotification-win32: Making use of worker thread

Closes #3869 and #3867

See merge request GNOME/glib!4975
2026-02-10 15:38:52 +01:00
otaxhu
fbbb745ce2 gnotification-win32: Returning early if notification body is invalid UTF-8 2026-02-10 10:00:57 -04:00
otaxhu
4777233f6b gnotification-win32: Making use of worker thread
- Creating and destroying the HWND in a worker thread.
- HWND message loop is handled in worker thread, currently only handling
  "TaskbarCreated" message to re-initialize the tray icon.
- send_notification waits for the notification icon to be created if it failed
  to call Shell_NotifyIcon(), or time out trying to wait.
2026-02-10 10:00:57 -04:00
Philip Withnall
f9ea3a7d20 Merge branch 'tvos' into 'main'
Disable or stub out fork/execv* usage when targeting tvOS and watchOS

See merge request GNOME/glib!4992
2026-02-09 15:41:57 +00:00
Philip Withnall
87ba602ddc gdbus-tool: Fix validation of method names
Method names weren’t previously validated in the argument parser, which
resulted in them being passed into the GDBus call, which would then
print a critical warning and abort.

Avoid that by validating them in the argument parser, and add a unit
test to prevent regressions.

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

Fixes: #3886
2026-02-06 19:32:36 +00:00
Philip Withnall
908b86fdff gdbus-tool: Add a basic test suite for the gdbus utility
It’s nowhere near complete, but it gives us somewhere to easily bolt new
tests in future.

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

Fixes: #3628
2026-02-06 19:32:29 +00:00
Philip Withnall
17f65eada2 gdbus-tool: Correctly handle gdbus --help argument
Previously it would print an error if called as `gdbus --help`. By
contrast, `gdbus help` worked as expected.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-06 16:36:50 +00:00
Nirbheek Chauhan
04badb981b gio: Don't build gio-launch-desktop when process spawning is disallowed
This uses execvp() which is disallowed on tvOS and watchOS.
2026-02-03 22:26:50 +05:30
Nirbheek Chauhan
1f76a92d51 gtestdbus: Compile-out fork() usage on tvOS/watchOS
The APIs will mostly error out early when trying to spawn processes,
but just in case they reach this point, explicitl g_error().
2026-02-03 22:26:50 +05:30
Philip Withnall
9cf30735f6 gresource: Fix some integers to be size_t
As they loop over arrays.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-03 12:45:20 +00:00
Philip Withnall
333f9a3911 gresource: Check for overflows with overlay calculations
The strings involved here all come from the `G_RESOURCE_OVERLAYS`
environment variable, so are all trusted as much as any other
environment variable (including `LD_PRELOAD`). Still, if one of them
ends up being too long, it would be better to skip that overlay than
crash.

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

Fixes: #3881
2026-02-03 12:38:33 +00:00
Philip Withnall
c3f585f9b0 gio-launch-desktop: Check for overflow in path provided for logging
It seems unlikely that this path would be long enough to cause an
overflow, but particularly given that we’re using `alloca()` here, we
should limit its length to prevent a possible stack overflow.

The path comes from the `GIO_LAUNCHED_DESKTOP_FILE` environment
variable, so is as trusted as any input from the environment (i.e. it’s
trusted; an untrusted environment can contain arbitrary `LD_PRELOAD`, so
has full permissions anyway).

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

Fixes: #3880
2026-02-03 12:26:40 +00:00
Luca Bacci
84931d5926 Use test-profile-dep in tests 2026-01-30 12:07:21 +01:00
Philip Withnall
bd0ae5b8e2 Merge branch 'disable-assert-fixup' into 'main'
gio/gdatainputstream: Mark bytes as potentially unused

See merge request GNOME/glib!4991
2026-01-27 17:25:17 +00:00
Marco Trevisan (Treviño)
6f1e3856eb gio/gdatainputstream: Mark bytes as potentially unused
The value is not used when compiling without assertions
2026-01-27 17:45:22 +01:00
Philip Withnall
bd5e783e1f Merge branch 'tosmessage' into 'main'
gio: Add GSocketControlMessage subclasses for receiving IP_TOS and IPV6_TCLASS

See merge request GNOME/glib!4846
2026-01-27 15:52:08 +00:00
Nirbheek Chauhan
905ae60475 giomodule: Simplify macOS macros further
Since we require macOS 11 (and 10.13 support is best-effort), we do
not need to support older than Xcode 8 which added TARGET_OS_OSX and
shipped with macOS 10.12.
2026-01-27 07:43:46 +05:30
Nirbheek Chauhan
67ebcc653e giomodule: Do not try to use GIO_MODULE_DIR on iOS
When we try to load that dir on a real phone, nothing happens because
the path doesn't exist since the app is a statically-linked bundle.
When we try on the simulator, we get warnings when the compiled-in
path exists in the user machine because the modules fail to load.
2026-01-27 07:06:19 +05:30
Nirbheek Chauhan
9adec080ab giomodule: Simplify macro usage for getting the giomodule dir
The original code is a bit hard to follow, and has one extra
allocation in the common case on macOS.
2026-01-27 07:06:19 +05:30