Commit Graph

8791 Commits

Author SHA1 Message Date
Roshan-R
c534037e12 meson: Fix project not compiling in macOS
Fixes: #3419
2024-07-28 19:50:30 +05:30
Nirbheek Chauhan
a4483644e8 meson: Fix another kqueue build race on macOS
`gobject-visibility.h` is also needed at build time. To reproduce the
error, just run `ninja gio/kqueue/libkqueue.a`
2024-07-27 08:03:42 +05:30
Philip Withnall
460d284fce
gcontenttype: Add platform-independent top level API file
This file doesn’t contain any real implementation, it just call the
`impl` functions from the platform-specific files
`gcontenttype-{fdo,osx,win32}.[cm]`.

It serves as a location for the doc comments, introspection annotations
and API preconditions, and will be built on every platform. In
particular, this means that we get consistent GIR output for the
`g_content_type_*()` APIs regardless of whether GLib was built on Linux or
Windows or macOS.

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

Helps: #3399
2024-07-24 17:46:31 +02:00
Philip Withnall
7bec6327a2
gio: Rename gcontenttype.c to gcontenttype-fdo.c
This reflects its status as actually platform-dependent: it’s only built
on systems using the freedesktop.org content type system.

It makes the file naming match up with other platform-specific
implementations, such as `gcontenttype-win32.c` and
`gcontenttype-osx.m`.

A subsequent commit will introduce a platform-independent high level API
wrapper so that the introspection annotations from this file can be
reused between platforms.

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

Helps: #3399
2024-07-24 17:46:25 +02:00
Philip Withnall
bf630dd4fd
gio: Rename gosxcontenttype.m to gcontenttype-osx.m
To make it consistent with the other platform-specific content type
implementations.

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

Helps: #3399
2024-07-24 17:46:19 +02:00
Philip Withnall
21fdb3be24
gappinfo: Move all platform-independent API docs to gappinfo.c
Previously, some of the doc comments for platform-independent APIs were
in `gdesktopappinfo.c`, which is only built on Unix systems. This meant
the introspection annotations for those APIs were not used on non-Unix
systems, which caused platform differences in `Gio-2.0.gir`.

So, move those doc comments to `gappinfo.c` and put them next to some
new platform-independent wrapper functions which provide a consistent
entry point and location for the API preconditions.

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

Helps: #3399
2024-07-24 17:45:22 +02:00
Philip Withnall
d1945c7abb
gdesktopappinfo: Add additional links to the Desktop Entry Spec
Might as well make it easy for people to look up what we’re talking
about.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-24 14:37:18 +02:00
Philip Withnall
c474d4065d
gdesktopappinfo: Port doc comments to gi-docgen syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-07-24 14:23:18 +02:00
Marco Trevisan (Treviño)
54d9c26b34 gcancellable: Reference the object before locking when doing signal emission
On g_cancellable_cancel() we were increasing the GCancellable ref count
before emitting the ::cancelled signal, this is a safe thing to do but
it was happening while the cancellable was locked, and this may have
potentially waken up some toggle notifications.

To prevent this, reference the GCancellable just before locking.
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
3a07b2abd4 GCancellable: Use per-instance mutex logic instead of global critical sections
GCancellable is meant to be used in multi-thread operations but all the
cancellable instances were sharing a single mutex to synchronize them
which can be less optimal when many instances are in place.
Especially when we're doing a lock/unlock dances that may leave another
thread to take the control of a critical section in an unexpected way.

This in fact was leading to some races in GCancellableSources causing
leaks because we were assuming that the "cancelled" callback was always
called before our dispose implementation.

As per this, use per-instance mutexes.

The lock is also now used only to protect the calls that may interact
with cancelled state or that depends on that, as per this we can just
reduce it to the cancel and reset case, other than to the connect one to
prevent the race that we could have when connecting to a cancellable
that is reset from another thread.

We don't really need to release the locks during callbacks now as they
are per instance, and there's really no function that we allowed to call
during a ::cancelled signal callback that may require an unlocked state.
This could been done in case with a recursive lock, that is easy enough
to implement but not really needed for this case.

Fixes: #2309, #2313
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
0a8cb10f22 gio/tests: Ensure that a GCancellableSource can be used muliple times
Closes: #774
2024-07-24 00:21:35 +02:00
Ondrej Holy
d9fec76b59 gfile: Add support for x-gvfs-trash mount option
Currently, the trash functionality is disabled for system internal mounts.
That might be a problem in some cases. The `x-gvfs-notrash` mount option
allows disabling the trash functionality for certain mounts. Let's add
support for the `x-gvfs-trash` mount option to allow the opposite.

See: https://issues.redhat.com/browse/RHEL-46828
2024-07-16 07:52:00 +02:00
Georges Basile Stavracas Neto
a84c67da71 gio/appinfo: Directly link GdkAppLaunchContext
We can only use the [class@Foo.Bar] syntax for identifiers under
namespaces included by the current namespace. Naturally, we cannot
include the GDK namespace.

Use a direct link for this instead.
2024-07-11 16:23:06 +01:00
Georges Basile Stavracas Neto
ecc9904996 gio/applaunchcontext: Port docs to gi-docgen
This one is a little more self-contained, even though the class name
doesn't match the file it is in.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
b8db83940b gio/appinfo: Port docs to gi-docgen
Adjust all docs to use the gi-docgen referencing syntax, reindent
some of the comments, and add missing annotations to some async
methods.

The error arguments are not necessary with gi-docgen so they're
removed.

Confusingly enough, the docks for GAppInfo is spread between two
files.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
110e76a140 gio/actionmap: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
3bd477b454 gio/actiongroupexporter: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Michael Catanzaro
4a73fbda8b Merge branch 'wip/pwithnall/resolver-parsing-bsd-fix' into 'main'
tests: Fix compilation of resolver-parsing test on FreeBSD

See merge request GNOME/glib!4152
2024-07-09 23:07:02 +00:00
Philip Withnall
fd2295c545 Merge branch 'port-gfilteroutputstream.c-comments' into 'main'
gfilteroutputstream.c: Port all doc comments to gi-docgen

See merge request GNOME/glib!4145
2024-07-09 22:54:47 +00:00
Philip Withnall
929f2ae06b
tests: Fix compilation of resolver-parsing test on FreeBSD
This fixes commit cdcb179808.

`dn_comp()` is needed to build fake DNS records for most of the tests in
this file. The new ownership test is no exception.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/4058481

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 21:41:03 +01:00
Philip Withnall
ef57fa8a29 Merge branch 'port-gbufferedinputstream.c-comments' into 'main'
gbufferedinputstream: Port all doc comments to gi-docgen

See merge request GNOME/glib!4146
2024-07-09 19:36:55 +00:00
Philip Withnall
fc01879341 Merge branch 'wip/pwithnall/macos-ci-fix' into 'main'
tests: Make an error check less specific in gsocketclient-slow

See merge request GNOME/glib!4149
2024-07-09 19:13:26 +00:00
Sudhanshu Tiwari
2e7e51be56 gbufferedinputstream: Port all doc comments to gi-docgen 2024-07-09 18:21:42 +01:00
Philip Withnall
325a9af5e0 Merge branch 'port-gbufferedoutputstream.c-comments' into 'main'
gbufferedoutputstream.c: Port doc comments to gi-docgen

See merge request GNOME/glib!4148
2024-07-09 17:01:46 +00:00
Philip Withnall
8d0bf4ed39
tests: Make an error check less specific in gsocketclient-slow
On Linux the error will be `G_IO_ERROR_CONNECTION_REFUSED`, but on macOS
it will be `G_IO_ERROR_TIMED_OUT`. Both errors seem reasonable to me, so
let’s not specifically require one of them.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4104#note_2161451

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 17:40:16 +01:00
Sudhanshu Tiwari
c48fd73189 gbufferedoutputstream.c: Port doc comments to gi-docgen 2024-07-09 18:03:03 +05:30
Sudhanshu Tiwari
a8b52cd9d6 gfilteroutputstream.c: Port all doc comments to gi-docgen 2024-07-09 17:30:32 +05:30
Leo Assini
202d345a82 GOsxNetworkMonitor: Add network monitor backend for OS X 2024-07-07 19:36:48 +00:00
Philip Withnall
3993d8db52
codegen: Drop unused import
This should have been dropped in commit
38faeca62e but somehow that didn’t happen
and somehow it wasn’t caught by the CI until afterwards.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/jobs/4049254

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-07 13:48:46 +01:00
Philip Withnall
8320085557 Merge branch 'andyholmes/resolver-ownership' into 'main'
gthreadedresolver: ref-sink returned records in lookup_records()

Closes #3393

See merge request GNOME/glib!4110
2024-07-05 06:26:51 +00:00
Andy Holmes
cdcb179808
tests: ensure DNS records are full-reference variants
For each test expected to return valid DNS records, test that the
record variants are not floating references.

Also add an test which checks this explicitly for a simple TXT record.
2024-07-04 17:37:44 -07:00
Benoit Pierre
caf7f8ef49 tests: fix some Windows testsuite failures
Add test dependencies on the 2 spawn helpers required on Windows.
2024-07-04 19:35:47 +00:00
Andy Holmes
da3510575e
gthreadedresolver: ref-sink returned records in lookup_records()
The return value to `lookup_records()` methods is set as `transfer full`
but the code path in `g_resolver_records_from_res_query()` doesn't
sink the GVariant.

Add the `g_variant_ref_sink()` call when prepending the record, so
the list hold a full reference on each records.

closes #3393
2024-07-04 12:06:12 -07:00
Philip Withnall
22d699943d Merge branch 'menu-model-diagram' into 'main'
Docs: Replace Gio.MenuModel diagram with SVG

See merge request GNOME/glib!4140
2024-07-04 11:55:11 +00:00
FeRD (Frank Dana)
f4d944119c Menu model example: Update diagram
- Add licensing tags
- Tweak spacing, colors, line thicknesses
- Create light-mode version
- Use `<picture>` tag to include appropriate version for each media
  color scheme.
2024-07-04 12:13:53 +01:00
FeRD (Frank Dana)
85c8a7c0d8 Docs: Replace Gio.MenuModel diagram with SVG
Recreate the `menu-model.png` diagram in SVG, with box outlines and
connectors recolored from black to white. This will allow the diagram
to show up better in the dark documentation theme.
2024-07-04 12:13:53 +01:00
Ernesto de Gracia Herranz
38faeca62e replace package.version.Version by internal code
This drops the dependency on the Python `packaging` module.

Signed-off-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
2024-07-04 11:04:38 +00:00
Yegor Yefremov
b89dba22cd codegen: resolve pylint import issues
Remove unused imports and reorder other imports so that
the standard ones are coming first.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-07-02 12:35:09 +02:00
Philip Withnall
1b41818f50 Merge branch 'port-gasyncresult.c-comments' into 'main'
gasyncresult: Port all doc comments to gi-docgen

See merge request GNOME/glib!4128
2024-07-01 13:44:42 +00:00
Gleb Popov
6daebde9a6 Fix gsocketclient-slow test on FreeBSD
The "port" variable ends up being 0 even after successful g_socket_bind.
Use g_socket_get_local_address() to actually get a correct port number.
2024-06-30 15:37:22 +03:00
Sudhanshu Tiwari
f08952d5fe gasyncresult.h: Port all doc comments to gi-docgen 2024-06-29 00:14:35 +05:30
Sudhanshu Tiwari
62acd02c49 gasyncresult.c: Port all doc comments to gi-docgen 2024-06-29 00:11:30 +05:30
Gary Li
d64336e1a9 g_output_stream_write: Allow NULL buffer if count is 0
We currently fail a buffer != NULL assertion if buffer is NULL and count is 0. Allow this case without critical assertions.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/3402
2024-06-26 14:18:41 -04:00
rong wang
478127e074 GLocalFile: support trashing long file name
When the file name is too long (for example, more than 238 bytes on
ext4), this will cause the creation of the .trashinfo file to fail.
Let's shorten the .trashinfo filename in this case, after all the
trash specification only requires unique filenames (see
`Contents of a trash directory` section in
https://specifications.freedesktop.org/trash-spec/trashspec-latest.html).
2024-06-19 10:27:33 +01:00
Philip Withnall
cce6ca8c88
tests: Improve 4GB file loading test to work on i386
This should test the limits of loading 4GB files on i386 platforms, such
as the Hurd CI runner. On such platforms, `sizeof(size_t) == 4`.

This should fix the compiler warning from
https://gitlab.gnome.org/GNOME/glib/-/jobs/3989442:
```
../gio/tests/file.c:2931:51: error: left shift count >= width of type [-Werror=shift-count-overflow]
 2931 | static const gsize testfile_4gb_size = ((gsize) 1 << 32) + (1 << 16); /* 4GB + a bit */
      |                                                   ^~
cc1: all warnings being treated as errors
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-18 12:58:51 +01:00
Philip Withnall
1f838b061b
tests: Skip >4GB file tests unless running tests in slow/thorough mode
They take too long to include in a normal test run. They’ll still be run
in CI once a week as part of our scheduled slow test job.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-17 13:03:08 +01:00
Philip Withnall
a8be45204e tests: Fix a typo in a test name in the file test suite
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-17 13:03:05 +01:00
Benjamin Otte
e74294473e tests: Add test for >4GB reads with g_file_load_contents()
The tests - one for sync, one for async - create a sparse file for
this purpose, so this should be cheap on the fileystem.

Of course, the test still allocates >4GB of memory for the data that it
returns from g_file_load_contents(), I hope the CI test runners can deal
with that.
2024-06-17 13:03:05 +01:00
Benjamin Otte
77c35415a3 tests: Use g_clear_fd() 2024-06-17 13:03:05 +01:00
Benjamin Otte
e8254f14fd gfile: Rewrite load_contents() to use realloc()
GByteArray is limited to 4GB in size and the current code silently
overflows when that happens.

Replace both load_contents() and load_contents_async() implementations
with a version that uses realloc() and gsize to maintain the array.
2024-06-17 13:03:05 +01:00