Commit Graph

26122 Commits

Author SHA1 Message Date
Peter Bloomfield
42826576a8 glib/tests/dataset: Test id_remove_multiple
Test that destroy-funcs are called in the order that the keys are
specified, not the order that they are found in the datalist.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
a4fa456e67 gdataset: Preserve destruction order
In `g_data_remove_internal()`, call the `GDataElt:destroy` functions in the
order that they appear in `keys`, instead of the order that they are found in
`datalist`.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
ac113c1ed2 In test_datalist_id_remove_multiple(), verify that the data list contains 3 items before calling g_datalist_id_remove_multiple(). 2022-06-23 17:41:55 -04:00
Peter Bloomfield
ad0f7199f1 glib/tests/dataset: Add a test
Test that `g_datalist_id_remove_multiple()` removes all the keys it is given.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
8c4598aab3 dataset: Do not increment
Do not increment the `data` pointer when it points to an item that has
not been inspected.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Hugo Carvalho
44bb5c26fc Update Portuguese translation 2022-06-23 21:39:02 +00:00
Philip Withnall
ac898b8e67 Merge branch 'fix-macos-again' into 'main'
tests: Fix type mismatches in new atomic tests when compiling with clang

See merge request GNOME/glib!2774
2022-06-23 18:44:13 +00:00
Marco Trevisan (Treviño)
00f3f0d407 gthread: Use atomic pointer exchange to check value set on g_init_leave 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
2c322f2a65 gmain: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
bfd77693ce gresource: Use atomic pointer exchange operations to nullify and check 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
9c32cfbaaa gfileattribute: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
576e5f2f87 cancellable: Use more atomic exchanges operations
We used to do get and set atomic operations pair, but these may be
unsafe in some cases as threads may rely on data that is changed in
in between them, however this is not a problem if we do exchange the
pointers.

So just use exchange ops, in this way we can avoid lock/unlock mutex
dances
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
920f54e795 gatomicarray: Use atomic exchange for data value
We can use pointer exchange now to avoid doing two operations to switch
to the new data pointer.

Since we're asserting in case of invalid data, we can just do this check
at later point, without involving any different behavior.

This changes in the unlikely case that G_DISABLE_ASSERT is defined, as in such
case we should undo the operation.
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
e7269a26e4 gio/tests: Ensure that a cancellable hangs if reset from cancellable callback 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
e218371f19 gio/tests: Ensure that cancellable is cancelled when emitting the signal
Use a race between threads resetting and cancelling a cancellable and
ensure that when we call the callback the cancellable is cancelled
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
62192925b6 gio/tests: Add tests for cancellable pollfd and cancellation callbacks 2022-06-23 20:01:12 +02:00
Philip Withnall
b5231ed003 Merge branch 'gthread-initial-cleanups' into 'main'
gthread: Some code cleanups and fixes

See merge request GNOME/glib!2775
2022-06-23 17:07:09 +00:00
Philip Withnall
191923ce61 Merge branch 'wip/smcv/none-flags' into 'main'
Add a NONE or DEFAULT member to most flags-sets

See merge request GNOME/glib!2576
2022-06-23 16:09:38 +00:00
Marco Trevisan (Treviño)
8d98617297 gthread-posix: Use named states to manage the mutex states
We used to use raw numbers to control the mutex state, we can use a
nicer enum to avoid dealing with pure numbers.
2022-06-23 17:50:12 +02:00
Marco Trevisan (Treviño)
15d2053122 glib/tests/autoptr: Also ensure that GRecMutexLocker can re-lock a mutex
It's native in the actual GRecMutex, but better to check that again.
2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
e2d2db6433 glib/tests/autoptr: Release the acquired locks on GRecMutex 2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
9dffecf5f5 gthread: Fix Since tag typo in documentation for some methods 2022-06-23 17:45:04 +02:00
Philip Withnall
35c4b640bb tests: Fix type mismatches in new atomic tests when compiling with clang
Clang seems to apply more rigorous type checks across the different
arguments to the atomic builtins. Fix various
`-Wincompatible-pointer-types`, `-Wpointer-sign` and `-Wint-conversion`
warnings.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-23 15:56:07 +01:00
Philip Withnall
d198edf9cd Merge branch 'leaks' into 'main'
gobject/tests/performance: fix leaks

See merge request GNOME/glib!2772
2022-06-23 13:47:33 +00:00
Philip Withnall
e5ccbe09da Merge branch 'atomic-exchange-pre-value' into 'main'
gatomic: Add Compare and Exchange functions that returns the previous value

See merge request GNOME/glib!2766
2022-06-23 13:19:05 +00:00
Marc-André Lureau
a5d551e2be gobject/tests/performance: fix leaks
Easily spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-23 17:18:21 +04:00
Philip Withnall
5655af6ada Merge branch 'more-async-gfile' into 'main'
gfile (and GAppInfo): Add some missing async APIs and ensure async calls always use them

See merge request GNOME/glib!2717
2022-06-23 11:49:55 +00:00
Philip Withnall
6529be2950 Merge branch 'ericLemanissier-main-patch-01384' into 'main'
use gvdb as a subproject

See merge request GNOME/glib!2771
2022-06-23 10:00:34 +00:00
Philip Withnall
ea7be5b249 Merge branch 'wip/smcv/atomic-pointer-exchange-docs' into 'main'
Correct documentation of g_atomic_pointer_exchange

See merge request GNOME/glib!2770
2022-06-23 09:58:23 +00:00
Simon McVittie
879b9cd669 gregex: Add G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:39 +01:00
Simon McVittie
0d4e401ede gmarkup: Add G_MARKUP_PARSE_FLAGS_NONE
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:27 +01:00
Simon McVittie
cef780e9ef giochannel: Add G_IO_FLAG_NONE
This makes the state where no flags are set a bit more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:22 +01:00
Simon McVittie
cc528f6c2e giomodule test: Don't pass a magic number to g_test_trap_subprocess()
This worked, but seems like bad style.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:19 +01:00
Simon McVittie
de8672fe0b gtestutils: Add G_TEST_SUBPROCESS_DEFAULT, G_TEST_TRAP_DEFAULT
This makes calls to test subprocesses with default behaviour more
self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:13 +01:00
Simon McVittie
f59e02a143 gioenums: Add G_TLS_CERTIFICATE_FLAGS_NONE
This makes the absence of flags (in other words, a valid certificate)
more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:05 +01:00
Simon McVittie
7045260c22 gsignal: Add G_CONNECT_DEFAULT
This makes calls to g_signal_connect_data() and g_signal_connect_object()
with default flags more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:46:45 +01:00
Simon McVittie
5e164c6615 gtype: Add G_TYPE_FLAG_NONE
This makes code that sets no flags a bit more self-documenting:
using G_TYPE_FLAG_NONE makes it clearer that no special behaviour is
required than literal 0, and clearer that there is no weird casting
between types than (GTypeFlags) 0.

GTypeFlags and GTypeFundamentalFlags occupy the same namespace and the
same bitfield, so I intentionally haven't added
G_TYPE_FUNDAMENTAL_FLAGS_NONE.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:45:31 +01:00
ericLemanissier
f2ea67ae44 use gvdb as a subproject
this fixes the build when using --wrap-mode=nofallback
fix proposed by @eschwartz
2022-06-23 08:26:21 +00:00
Simon McVittie
69f7b03c38 Correct documentation of g_atomic_pointer_exchange
The references to gint and guint were copy/pasted from
g_atomic_int_exchange(), but what we want here is a gpointer, gintptr
or guintptr like the rest of the g_atomic_pointer_ family.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 09:20:35 +01:00
Marco Trevisan (Treviño)
922bc1d995 build: Use _GLIB prefix for GCC features we detected at build time
We used a _GCC prefix that is not our namesapce, so even if such value
is not provided by the compiler, let's just use a better name.
2022-06-22 23:01:33 +02:00
Marco Trevisan (Treviño)
bfdeb37f6e gatomic: Add Compare and Exchange functions that returns the previous value
Atomic primitives allow to do conditional compare and exchange but also
to get the value that was previously stored in the atomic variable.

Now, we provided an exchange function that allows to do an exchange if
the atomic value matches an expected value but we had no way to know
at the same time what was the value in the atomic at the moment of the
exchange try, an this can be useful in case that the operation fails,
for example if the current value is still acceptable for us, allowing
to do a kind of "OR" check:

  gint old_value;
  gint valid_value = 222;
  while (!g_atomic_pointer_compare_and_exchange_value (&atomic,
                                                       valid_value, 555,
                                                       &old_value)
    {
      if (old_value == 555 || old_value == 222)
        valid_value = old_value;
    }
2022-06-22 23:01:19 +02:00
Marco Trevisan
cb0cc996ee Merge branch 'test-suite-fixes' into 'main'
tests: Various fixes for TAP output of tests

See merge request GNOME/glib!2749
2022-06-22 18:48:59 +00:00
Marco Trevisan (Treviño)
5b04d23fc4 gfile: Make g_query_default_handler_async really Async
Despite the name, the call was still doing blocking operations when
looking for app handlers via GAppInfo. Now it's possible to use fully
async calls.

Together with previous commit, the API is now fully async.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
8a880e1379 GAppInfo: Make g_app_info_launch_default_for_uri_async fully async
Despite the name, we still used blocking calls to get the default app
for URI, now that we have an async implementation of the API to get the
default implementation for URI scheme, we can remove the blocking calls.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
8aee5fc628 GAppInfo: Add async API to get default Application for URI scheme
Make possible to fetch the default application for URI scheme in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
73b29e8f6e gio/tests: Add test case for g_app_info_launch_default_for_uri
We did not check whether this function worked before, so add a simple
test case for it, providing some test functions to make it possible to
reply the same behavior
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
eee15225c7 GDesktopAppInfo: Ignore flushing the session bus when there's not
In some cases (such as in our CI tests) we may not have any dbus session
set after launching, but we always assumed so.

In case we have not a session bus set, we only have to return early.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
6fef60b65c GDesktopAppInfo: Ensure that URI scheme is a valid argument 2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
c87602451c gfile: Use async API to get the default GAppInfo for type
In both callbacks of g_file_query_default_handler_async() we were
actually using I/O blocking APIs making it not fully async.

Now that such API is provided, we can use it.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
44dbd43170 GAppInfo: Add async API to get default Application for content type
Make possible to fetch the Application for default content type in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00