Commit Graph

27453 Commits

Author SHA1 Message Date
Simon McVittie
0d86ee0a86 gstdio: Improve documentation of g_clear_fd() as async-signal safe
Add cross-references as requested for similar new API in !3457.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-31 16:34:16 +01:00
Simon McVittie
9af6b7e4e7 gstdio: Improve documentation of g_close() as async-signal safe
Add cross-references as requested for similar new API in !3457.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-31 16:34:14 +01:00
Philip Withnall
7a82da2992 Merge branch 'wip/smcv/steal-fd-preserves-errno' into 'main'
gmain: Document that g_steal_fd() preserves errno

See merge request GNOME/glib!3456
2023-05-31 14:34:33 +00:00
Philip Withnall
2d6073fae2 Merge branch 'symlink-target-filename' into 'main'
gfileinfo: add (type filename) annotation to symlink_target functions

See merge request GNOME/glib!3455
2023-05-31 08:46:13 +00:00
Jason Francis
c556a4d8f8
gfileinfo: add (type filename) annotation to symlink_target functions 2023-05-31 00:54:38 -04:00
Emmanuele Bassi
6fc6d9ea3e Merge branch 'ebassi/keyfile-docs' into 'main'
docs: Use the type name as the section name for GKeyFile

See merge request GNOME/glib!3453
2023-05-31 01:05:34 +00:00
Emmanuele Bassi
e8440ddcf9 Merge branch 'ebassi/type-table-docs' into 'main'
Allow proper introspection of GTypeValueTable

See merge request GNOME/glib!3441
2023-05-30 23:26:54 +00:00
Michael Catanzaro
b7d5e4bc19 Merge branch 'mcatanzaro/#2832' into 'main'
Fix: GSocketClient cannot proxy connect unless default port is explicitly specified in proxy URL

Closes #2832

See merge request GNOME/glib!3451
2023-05-30 16:50:40 +00:00
Simon McVittie
c97348428f gmain: Document that g_steal_fd() preserves errno
This is useful when writing similarly low-level code, and was always true
as implemented here; let's document it so that other codebases can rely
on it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-30 16:02:16 +01:00
Michael Catanzaro
d624c850b2 Add some tests for socks:// URI default ports
This also tests socks5h:// which we don't actually support yet, just to
make sure it works, which it does.
2023-05-30 09:55:39 -05: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
Michael Catanzaro
42cb8dfb95 guri: the default port for SOCKS URLs is 1080
This is true for socks://, socks4://, socks4a://, and socks5://. I could
list them individually and risk breaking in the future if socks6:// ever
exists, or test for "socks" and risk breaking if a future URL scheme
begins with "socks" but doesn't use port 1080. I picked the latter.
2023-05-30 09:49:43 -05:00
Philip Withnall
5c50aec060 Merge branch 'glib-mkenums_parse_trigraph' into 'main'
Take double-quote characters into account when parsing trigraph

Closes #65

See merge request GNOME/glib!3452
2023-05-30 14:45:54 +00:00
Philip Withnall
fe458559d8 Merge branch 'gsignal-emission-locks-cleanups' into 'main'
gsignal: Reduce lock/unlock pairs and ensure we always work on valid signal nodes

See merge request GNOME/glib!2824
2023-05-30 13:57:27 +00:00
Emmanuele Bassi
d4f2db270f Annotate GTypeValueTable callbacks for availability
The compiler annotations are mainly useful for people using the symbols
directly.

To avoid getting compiler warnings for the GTypeValueTable definition
itself, we need to wrap the structure with
G_GNUC_BEGIN_IGNORE_DEPRECATIONS and G_GNUC_END_IGNORE_DEPRECATIONS.
2023-05-30 14:38:16 +01:00
Emmanuele Bassi
23a9dbdaf6 Allow proper introspection of GTypeValueTable
The introspection scanner cannot deal very well with function pointers
into a plain structure. In order to document the various function
pointers in GTypeValueTable we need to create typed callbacks, and
use them to replace the anonymous function pointers inside the
structure. This not only allows us to properly document the function
pointers, but it also allows us to annotate the arguments and return
value of those function pointers.

See also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/400#note_1721707
2023-05-30 14:38:16 +01:00
Philip Withnall
32ec11e51d Merge branch 'free-sized-macro' into 'main'
gmem: Add an inline definition of g_free() to automatically use g_free_sized()

See merge request GNOME/glib!3252
2023-05-30 13:29:25 +00:00
Emmanuel Fleury
7e5607d534 Take double-quote characters into account when parsing trigraph
For now, the function parse_trigraph() defined in gobject/glib-mkenums
script was not taking double-quotes characters into account:

>>> parse_trigraph('name="eek, a comma"')
{'name': '"eek', 'a': None}

This patch take double-quotes characters into account:

>>> parse_trigraph('name="eek, a comma"')
{'name': 'eek, a comma'}

Closes issue #65
2023-05-30 15:22:05 +02: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
Marco Trevisan (Treviño)
2e1ceb9563 gsignals: Do not zero two times the instance GValue's GType
We already use g_new0 to create such arrays and nothing writes in the first
pointer till this point, so no need to zero it again.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
76ed55f3a7 gsignal: Use static allocation if we've just few emission hooks
Normally we don't really have emission hooks around, so try to allocate
only tiny array to contain a few of them and in case we exceed that limit,
we go back to use allocated ones.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
bfc599b8a2 gsignal: Reduce lock/unlock operations when calling signal_emit_unlocked_R
We used to call this function as unlocked, with a node value that
could be invalid at the point of the call, so let's ensure that when
we call such function it's defined, and then reduce the access to the
signal node members when we're unlocked or after a lock/unlock operation
that may have changed it.

As per this, add more tests handling multiple signal hooks cases that we
did not cover before.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
e5ee6e141d gsignal: Cleanup g_signal_emitv splitting it in locked and unlocked paths
It just makes code easier to maintain and more clearly scoped.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
f011910395 gsignal: Do not try to access to node members when unlocked
In g_signal_emit_valist() we used to access to param types array and
n_params values after unlocking the mutex, and this might have lead to
making such values unreliable for the current call.

So let's keep them around until we're done with the function call
2023-05-30 13:52:07 +01:00
Marco Trevisan (Treviño)
2368187eb9 gsignal: Avoid possible race in g_signal_emit_by_name
Since we're locking and unlocking once we've found the signal ID, we
might have performed calls to g_signal_emit_valist() with a signal id
that was already been removed, and thus failing later.

This is not really an issue as inside g_signal_emit_valist() we were
re-checking for the signal id, but we can make this more reliable so
that the first thread that acquires the lock can also be sure to emit.
2023-05-30 13:52:07 +01:00
Marco Trevisan (Treviño)
0bc725d4fe gobject/tests/signals: Add tests for g_object_emitv
It's very much used by bindings but we didn't really test it locally.
2023-05-30 13:52:07 +01:00
Philip Withnall
c0bdc61879 meson: Export HAVE_FREE_SIZED in glibconfig.h for use in g_free()
This allows the `g_free()` wrapper introduced in the previous commit to
only be defined if `free_sized()` is actually available to improve
performance.

This avoids passing an allocation size to every `g_free()` call if it’s
not going to be used, saving a register store instruction each time.

Suggested by Marco Trevisan in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3252#note_1660032

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 13:45:05 +01:00
Marco Trevisan (Treviño)
c580b5c2f4 gmem: Add an inline definition of g_free() to automatically use g_free_sized()
When using GCC we can take the advantage of __builtin_object_size() to
know the allocated size of a memory area, this generally only works when
some optimization level enabled (-O1 seems enough here) and can provide
us with memory size information for lower-level optimizations.
2023-05-30 13:43:25 +01:00
Emmanuele Bassi
28e8f5c136 docs: Rename the GBookmarkFile section
Use the type name, to ensure that the section docblock gets merged into
the type docblock in the introspection data.

Helps: #2961
2023-05-30 13:33:45 +01: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
Emmanuele Bassi
4386d912d7 docs: Use the type name as the section name for GKeyFile
Without this, the section docblock for GKeyFile disappears into the
ether when generating the introspection data.

Helps: #2961
2023-05-30 12:46:30 +01: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
Philip Withnall
153c7f7b99 Merge branch 'wip/p3732/truncate-middle' into 'main'
gutf8: Add a g_utf8_truncate_middle() function

See merge request GNOME/glib!3440
2023-05-30 11:02:03 +00:00
Sabri Ünal
49971ee217 Update Turkish translation 2023-05-26 23:05:00 +00:00
Philip Withnall
57087ff42d Merge branch 'remove-action-entries' into 'main'
gactionmap: Add g_action_map_remove_action_entries()

See merge request GNOME/glib!3450
2023-05-26 09:47:30 +00: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
Patrick Griffis
ec9e7b5487 Merge branch 'more-docs' into 'main'
docs: Move README.win32.md to the docs folder and update CONTRIBUTING.md

See merge request GNOME/glib!3449
2023-05-25 13:56:43 +00:00
Peter Eisenmann
cd3837174b gutf8: Add a g_utf8_truncate_middle() function
Adds a helper to truncate UTF8 strings in the middle, allowing to make
them fit certain size constraints.

This function is modeled after similar functionality that has existed
since 2008 in nautilus and in eel before that.
2023-05-25 00:36:56 +02:00
Philip Withnall
716bd4dfd7 docs: Update meson example commands
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:35:33 +01:00
Philip Withnall
c217e5905c docs: Don’t mention pushing directly to origin
If people do that, it clutters the place up with branches which are not
deleted-on-merge by default. Better to use their own forks.

And the people who are in a position to be able to push directly to
`origin` are not going to be reading the `CONTRIBUTING.md` file, so this
paragraph is noise to most readers anyway.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:34:57 +01:00
Philip Withnall
5212171d0e docs: Suggest that new APIs don’t have to be in GLib
GLib can’t grow forever, so we should really only be accepting APIs
which are useful across a variety of projects and which couldn’t easily
live in a separate library.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:33:22 +01:00
Philip Withnall
d608ceedb3 docs: Update security instructions in CONTRIBUTING.md
Point strongly towards `SECURITY.md` so we are not maintaining security
instructions in multiple places.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:32:54 +01:00
Philip Withnall
c9ea59b888 docs: Mention Matrix rather than IRC in CONTRIBUTING.md
GNOME as a whole has moved to Matrix.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:32:39 +01:00
Philip Withnall
f6f250fc38 docs: Move README.win32.md to the docs folder
It’s a bit confusing to have two files called `README`, especially given
that `README.win32.md` only contains build instructions and none of the
other overview/contribution/bug reporting information that `README.md`
contains.

It feels like these would be better organised by having one top-level
`README.md`, and pointing to the Windows build instructions from there.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-24 16:19:47 +01: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