Commit Graph

28084 Commits

Author SHA1 Message Date
Philip Withnall
1f59981f7f Merge branch 'th/fix-main-context-release-owner-check' into 'main'
gmain: drop owner check assertion in g_main_context_release()

Closes #3054

See merge request GNOME/glib!3513
2023-07-30 10:09:09 +00:00
Emmanuele Bassi
7211c07693 Merge branch '623-type-query-dynamic' into 'main'
gtype: Allow g_type_query() to be called on dynamic types

Closes #623

See merge request GNOME/glib!3516
2023-07-30 09:04:35 +00:00
Thomas Haller
07f8a5daa3 gmain: drop owner check assertion in g_main_context_release()
As commit 44616ebafd ('gmain: More explicitly document
g_main_context_release() prereqs') correctly notes, you need to have the
context acquired before releasing it (just like a ref must match an
unref).

Commit 3926af723a ('gmain: Add precondition assertions to
g_main_context_release()') then goes one step further, and requires that
the calling thread is also the owner (the thread, that acquired the
context).

This is something which has been documented by g_main_context_release()
for years:
> Releases ownership of a context previously acquired **by this thread**

With acquire/release and g_main_context_is_owner() we track the thread
that acquired the context. That is mainly useful for asserting
correctness to not accessing the context from an unexpected thread.
Note that g_main_context_acquire() returns FALSE and does nothing when
the context is already acquired from another thread. Methods like
g_main_context_{prepare,query,dispatch}() require that the calling
thread is the owner (although, they don't assert for that, which they
maybe should).

With the assertion, it means you cannot pass an acquired context to
another thread for release. Obviously, if you pass on an acquired
context to another thread, the only next thing you can do is
g_main_context_release() (no acquire,prepare,query,dispatch). But it's
still useful to be able to release it, and to be able to keep it
acquired for a prolonged time.

libnm needs that, as it integrates a GMainContext into another
GMainContext. For that, it needs to acquire the inner context and keep
it acquired for as long as the context is integrated. Otherwise, when a
source gets attached to the inner context, the inner context is not
woken up (see g_source_attach_unlocked()). In commit e26a8a5981 ('Add
G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING'), a flag was introduced to solve
that same problem, without keeping the inner context acquired all the
time. Note that G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING is a flag of the
GMainContext, so it only works if the user who integrates the inner
context also controls how the context was created.  For libnm, having
the inner context acquired at all times is no problem, because it's
understood that the user gives up agency on the inner context while it's
integrated. The only thing to consider is that the outer context might
be iterated on another thread. When calling prepare,query,dispatch on
the inner context, the code will notice it, release the inner context
and re-acquire it on the new thread ([1]).  This works just fine, but it
requires that g_main_context_release() works from any thread.

So, in order to not break NetworkManager, let’s drop the ownership
assertion. However, NetworkManager is strictly breaking the API contract
here, and GLib reserves the right to re-add this assertion in future.

Still keep the assertion for the owner_count.

(Commit and commit message significantly updated by Philip Withnall; all
errors are his.)

[1] 9f01cff04f/src/libnm-glib-aux/nm-shared-utils.c (L4944)

Related: 3926af723a ('gmain: Add precondition assertions to g_main_context_release()')
Related: c67dd9d3fe ('gmain: Add a missing return on error path in g_main_context_release()')

Closes #3054
2023-07-30 11:53:34 +03:00
Philip Withnall
d9b23c5466 gtype: Allow g_type_query() to be called on dynamic types
There’s no reason that anyone can think of that this should be
disallowed. It’s useful for language runtimes like GJS to be able to
find out the allocation size of dynamic GObjects.

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

Fixes: #623
2023-07-30 11:25:42 +03:00
Matej Urbančič
43cec2d622 Update Slovenian translation 2023-07-29 13:42:00 +00:00
Philip Withnall
02bc1382b2 gnetworkmonitor: Expand guidelines for metered data use
Clarify how much is too much.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-29 15:22:15 +03:00
Philip Withnall
627dc1415c Revert "build-sys: drop -mms-bitfields GCC flag"
This reverts commit 252bbcd207.

After further discussion in !3511, we’ve decided that there are risks
associated with this change, and it’s not the best way of addressing the
original problem.

The original motivation for the change turned out to be that
`-mms-bitfields` was not handled by `windres`, which was receiving it
from `pkg-config --cflags glib-2.0` in some projects. However, if
`windres` is claiming to accept CFLAGS then it should accept (and
ignore) `-mms-bitfields`, since the `-m` family of options are defined
in `man gcc`, just like `-I`, `-D`, etc.

There is some question that there might still be third party projects
which are built with an old enough compiler that `-mms-bitfields` is not
the compiler default. For that reason, we should either still continue
to specify `-mms-bitfields` in the `.pc` file, or add a test to assert
that third party projects are always compiled with `-mms-bitfields` set.
But adding a new test for all third-party compilations is risky (if we
get it wrong, things will break; and it’s a test which may behave
differently on different platforms), so it seems safer to just keep
`-mms-bitfields` in `.pc` for now.

Once all compilers which we require specify `-mms-bitfields` by default,
we can finally drop this flag (without adding a test for third-party
compilations).

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3511
2023-07-29 11:54:22 +03:00
Danial Behzadi
6e77bb3315 Update Persian translation 2023-07-29 01:46:42 +00:00
Danial Behzadi
74b1f636b7 Update Persian translation 2023-07-29 01:45:00 +00:00
Yuri Chornoivan
17bfd6c9a5 Update Ukrainian translation 2023-07-28 17:48:10 +00:00
Philip Withnall
39864716d6 Merge branch 'fix_3050' into 'main'
Strip query sections from file: URIs

Closes #3050

See merge request GNOME/glib!3502
2023-07-28 12:52:36 +00:00
Lukáš Tyrychtr
b504cc0841 gfile: Strip query sections from file: URIs
According to https://url.spec.whatwg.org/#file-state
a file URI can have a fragment and query string, so just ignore them
and don't raise an invalid URI error.

Fixes: #3050
2023-07-28 15:04:49 +03:00
Philip Withnall
215a6ed80c gconvert: Rename an internal variable
The old name was not quite correct: the part of a URI which is just past
the scheme might be the hostname or the path. It isn’t necessarily just
a path.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-28 15:04:49 +03:00
Yosef Or Boczko
67eb8f112f Update Hebrew translation 2023-07-28 06:00:39 +00:00
Ekaterine Papava
782b06d92f Update Georgian translation 2023-07-28 05:15:30 +00:00
Balázs Úr
7e9db39996 Update Hungarian translation 2023-07-26 23:43:43 +00:00
Michael Catanzaro
b01d801207 Merge branch 'issue-2929' into 'main'
Fix build race between gio subdirs and gversionmacros.h

Closes #2929

See merge request GNOME/glib!3512
2023-07-26 17:36:05 +00:00
Simon McVittie
9d203a9e39 Merge branch 'wip/smcv/prctl-undumpable' into 'main'
testutils: Use prctl PR_SET_DUMPABLE to silence core dumps on Linux

See merge request GNOME/glib!3510
2023-07-26 15:06:07 +00:00
Simon McVittie
71d44e8d71 testutils: Use prctl PR_SET_DUMPABLE to silence core dumps on Linux
Otherwise, crashing tests like assert-msg-test will still report to
pipe-based crash reporting frameworks like systemd-coredump, even though
the RLIMIT_CORE limit is zero.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-26 15:42:06 +01:00
Simon McVittie
be2c9220d6 testutils: Factor out g_test_disable_crash_reporting()
We're already repeating this in 4 places, and in a subsequent commit
I'll extend it to do more.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-26 15:41:47 +01:00
Eric van Gyzen
6b4b4cd889 Fix build race between gio subdirs and gversionmacros.h
I made the kqueue failure 100% reliable with `samu -j1` on FreeBSD,
and therefore confirmed this fixes that problem.  Issue #2929 is
an identical failure on win32, so I assume this fixes that, too,
but I haven't confirmed.

Fixes: #2929
2023-07-25 20:28:20 -05:00
Philip Withnall
e051f4abaf Merge branch 'win32' into 'main'
build-sys: drop -mms-bitfields GCC flag

See merge request GNOME/glib!3509
2023-07-24 15:52:10 +00:00
Marc-André Lureau
252bbcd207 build-sys: drop -mms-bitfields GCC flag
This flag is problematic for some usages, and is no longer needed since
~2012 GCC 4.7 (https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a6c467624ade35128)

It is dropped from MINGW since:
https://github.com/msys2/MINGW-packages/pull/12891

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-07-24 14:45:09 +04:00
Philip Withnall
9b80774ca7 Merge branch 'fileinfo-filepath' into 'main'
gfileinfo: add file_path methods for language bindings

See merge request GNOME/glib!3461
2023-07-22 05:27:12 +00:00
Philip Withnall
be6c9fc410 Merge branch 'wip/antoniof/transfer-full-strv' into 'main'
strfuncs: Add missing ownership annotations for returned string vectors

See merge request GNOME/glib!3499
2023-07-21 21:20:58 +00:00
Jason Francis
04b683c34f gfileinfo: add file_path methods for language bindings
Including some tests by Philip Withnall.
2023-07-21 21:24:50 +01:00
Philip Withnall
b4a6343a5c Merge branch 'mcatanzaro/closure-audit' into 'main'
Audit and fix incorrect use of (closure) in glib

See merge request GNOME/glib!3287
2023-07-21 19:20:07 +00:00
Michael Catanzaro
12e48719af Fix scope annotation on g_file_move_async()
Currently the callback is invalid after the call to g_file_move_async(),
before g_file_move_finish() is called. That is no bueno.
2023-07-21 19:04:37 +01:00
Michael Catanzaro
5d738ddcfe Audit and fix incorrect use of (closure) in glib
Following Emmanuele's instructions for use of introspection annotations:

https://www.bassi.io/articles/2023/02/20/bindable-api-2023/

I have audited all uses of the (closure) annotation in glib and
determined that only a handful are correct. This commit changes almost
all of our use of (closure) annotations to conform to Emmanuele's rules.
2023-07-21 19:03:57 +01:00
António Fernandes
28dd5f017d strfuncs: Add missing ownership annotations for returned string vectors 2023-07-21 18:47:52 +01:00
Allison Karlitskaya
55abdd5e4a GVariant: add probes for SystemTap
https://bugzilla.gnome.org/show_bug.cgi?id=662779
Fixes: #473
2023-07-21 18:40:13 +01:00
Philip Withnall
3ab16a0d18 Merge branch 'libintl_fallback' into 'main'
meson: Allow forcing fallback for libintl

Closes #3048

See merge request GNOME/glib!3497
2023-07-21 16:44:56 +00:00
Allison Karlitskaya
766663dafe GPrivate: eliminate a malloc for pthread_key_t on most platforms
We don't know how big a pthread_key_t is, so we malloc() a big enough
chunk of memory for it and store a pointer into the GPrivate struct.

It turns out, on Linux, pthread_key_t is just an int, so we could much
easier just store it directly into the struct.

https://bugzilla.gnome.org/show_bug.cgi?id=737445
Fixes: #931
2023-07-21 17:12:01 +01:00
Allison Karlitskaya
256b195ff1 GPrivate: change return type of internal function
g_private_get_impl() was returning a pointer to the pthread_key_t, but every
function using this was immediately dereferencing it.  Change it so that we
dereference the value in the helper function and return it by value.

https://bugzilla.gnome.org/show_bug.cgi?id=737445
2023-07-21 17:03:31 +01:00
Michael Catanzaro
a552bf5694 Merge branch 'revert3356' into 'main'
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"

See merge request GNOME/glib!3504
2023-07-20 15:20:58 +00:00
Philip Withnall
9cb52d9f3b Merge branch '3045-multiarch-tests' into 'main'
tests: Fix pkg-config test for multiarch binaries on multiarch systems

Closes #3045

See merge request GNOME/glib!3506
2023-07-20 13:29:51 +00:00
Philip Withnall
2b391227e6 tests: Fix pkg-config test for multiarch binaries on multiarch systems
The test was passing fine when `bindir` was equal to `multiarch_bindir`,
but not when they differ.

For example, on a Debian system, `gio-querymodules` is installed to
`/usr/lib/x86_64-linux-gnu/glib-2.0/gio-querymodules` rather than
`/usr/bin/gio-querymodules` as it is on (say) Fedora.

This was causing the pkg-config tests to fail on Debian.

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

Fixes: #3045
2023-07-20 13:30:34 +01:00
Philip Withnall
04f81e167e Merge branch 'subprojects-dir' into 'main'
meson: help gobject-introspection locate source and build dirs

See merge request GNOME/glib!3505
2023-07-20 12:22:38 +00:00
Philip Withnall
b16e682112 Merge branch 'keyfile-regression-3047' into 'main'
gkeyfile: Fix regression #3047 (group comment)

Closes #3047

See merge request GNOME/glib!3498
2023-07-20 11:59:07 +00:00
Andoni Morales Alastruey
dc37ca70fe meson: help gobject-introspection locate source and build dirs
gobject-introspection is currently assuming glib subproject
is in unversioned, but gstreamer uses a versioned directory, eg:
subprojects/glib-2.74.1 instead of subprojects/glib
2023-07-20 10:49:26 +02:00
Harald van Dijk
6e29fbec2d
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"
This reverts commit 004f48f4fc.

Per the discussion on #3356, this change was prompted by a
misunderstanding of ldflags/link_args, and it resulted in various other
packages using glib no longer getting symbols exported. This commit
restores the glib 2.76 behaviour.
2023-07-18 18:26:49 +01:00
Marco Trevisan
674f2a030c Merge branch '3054-context-return' into 'main'
gmain: Add a missing return on error path in g_main_context_release()

Closes #3054

See merge request GNOME/glib!3501
2023-07-18 10:57:32 +00:00
Philip Withnall
c67dd9d3fe gmain: Add a missing return on error path in g_main_context_release()
This should have been in commit
3926af723a.

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

Fixes: #3054
2023-07-18 11:31:01 +01:00
Philip Withnall
741a561c4d Merge branch 'supported-platforms-docs' into 'main'
docs: Expand supported platforms documentation a little

See merge request GNOME/glib!3485
2023-07-14 11:57:03 +00:00
Brendan Shanks
d0862c3692 meson: Allow forcing fallback for libintl
Closes #3048
2023-07-13 10:02:04 -07:00
Philip Withnall
5d6c044da4 Merge branch 'wip/corey/codegen-typecheck' into 'main'
gdbus-codegen: Error on invalid dbus types

See merge request GNOME/glib!3495
2023-07-13 10:06:08 +00:00
Gaël Bonithon
51dfb3c229 gkeyfile: Skip group comment when adding a new key to a group
An oversight in 86b4b045: since the comment of group N now consists of
the last null-key values of group N-1, these keys must obviously be
skipped when adding a new non-null key to group N-1.

Closes: #3047
Fixes: 86b4b0453e
2023-07-13 10:32:18 +02:00
Gaël Bonithon
c49502582f gkeyfile: Ensure we don't add extra blank line above new group
A forgotten edge case in 86b4b045: when the last value of the last group
has been added via g_key_file_set_value() and it contains line breaks.
The best we can do in this case is probably to do nothing.

Closes: #3047
Fixes: 86b4b0453e
2023-07-13 10:32:18 +02:00
Corey Berla
a1a00a3071 gdbus-codegen: Error on invalid dbus types
Introduce slightly modified (dbus specific) versions of
variant_is_signature and variant_type_string_scan in order to fail
early on bad type strings.
2023-07-12 15:33:22 -07:00
Philip Withnall
f4df750075 Merge branch 'ptr-array-sort' into 'main'
garray: Fix typo in doc comment of g_ptr_array_sort[_with_data]()

See merge request GNOME/glib!3496
2023-07-12 12:32:43 +00:00