Commit Graph

2088 Commits

Author SHA1 Message Date
Simon McVittie
86d4da1634 gobject: Add a test for deprecated properties
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 10:27:55 +01:00
Simon McVittie
e974c81d0a gobject: Only emit deprecation warnings for user-specified properties
If a deprecated property only gets set because it is G_PARAM_CONSTRUCT
or G_PARAM_CONSTRUCT_ONLY, then there is nothing for the library user
to fix, and we should not emit a deprecation warning.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 10:27:55 +01:00
Marco Trevisan
22f0522c10 Merge branch 'mcatanzaro/gtype-criticals' into 'main'
Replace most GObject warnings with criticals

See merge request GNOME/glib!2852
2022-09-19 14:35:12 +00:00
Marco Trevisan
d29e936a6c Merge branch 'mkenum-build-fix' into 'main'
glib-mkenums: Specify output encoding as UTF-8 explicitly for non-English locale

See merge request GNOME/glib!2857
2022-09-19 14:34:01 +00:00
Tom Levy
eeaef8b950 docs: Improve wording in documentation of g_unix_signal_source_new()
- Insert missing word "from".

- Remove space between function name and "()" so syntax highlighting
  can recognise it as a function.

- Avoid "you"/"your" when discussing the reentrancy issues of regular
  UNIX signal handlers, because it gives the false impression that
  these issues are applicable to g_unix_signal_source_new().

Unrelated:

- Fix missing space in documentation of g_signal_new_class_handler().
2022-09-16 08:25:46 +00:00
Sebastian Dröge
d41b5bf999 Revert "Merge branch 'wip/smcv/deprecated-construct-prop' into 'main'"
This reverts merge request !2888
2022-09-13 11:20:03 +00:00
Simon McVittie
fef0408eaa gobject: Add a test for deprecated properties
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-13 11:20:45 +01:00
Simon McVittie
b88474ee7c gobject: Only emit deprecation warnings for user-specified properties
If a deprecated property only gets set because it is G_PARAM_CONSTRUCT
or G_PARAM_CONSTRUCT_ONLY, then there is nothing for the library user
to fix, and we should not emit a deprecation warning.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-13 11:16:58 +01:00
Xavier Claessens
a1c78d63ef meson: Set install_tag on all tools
Those tools are not needed at runtime for typical applications,
distributions typically package them separately.

This makes `meson install --tag runtime` skip installation of those
tools. Omitting `--tag` argument will still install them, as well as
with `--tag bin,bin-devel`.

See https://mesonbuild.com/Installing.html#installation-tags.
2022-09-12 09:50:31 -04:00
Emmanuele Bassi
903c004b37 Fix array-bounds compiler warnings with GCC 12
GCC isn't smart enough to recognise that the assertion on the size of
N_PROPERTIES also affects the assertion on the GParamSpec array access,
so we need to coalesce the two checks into one to avoid an array-bounds
compiler warning.
2022-09-02 12:46:57 +01:00
Andy Holmes
79c70d7a36
gparamspec: mark nick/blurb as nullable
GParamSpec nicks and blurbs are effectively a deprecated feature,
or at least unused by most libraries these days. Since a number
of C libraries (i.e. GTK4) have started to null these out, annotate
them as `(nullable)` so bindings can do the same.

Closes #2719
2022-08-21 15:52:38 -07:00
Seungha Yang
ebcc3c01db glib-mkenums: Specify output encoding as UTF-8 explicitly for non-English locale
Fixup regression introduced by
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2797
2022-08-16 04:53:34 +09:00
Michael Catanzaro
0ffe86a1f7 Replace most GObject warnings with criticals
All of these warnings indicate programmer error, so critical is most
appropriate here.

Exceptions: deprecation warnings are just warnings. Also, warnings that
are worded with uncertainty can remain warnings rather than criticals.
2022-08-09 13:18:47 -05:00
Emmanuele Bassi
8f68c1e646 Rename G_MARKUP_PARSE_FLAGS_NONE
The prefix for GMarkupParseFlags enumeration members is G_MARKUP; this
means that G_MARKUP_PARSE_FLAGS_NONE gets split into
GLib.MarkupParseFlags.PARSE_FLAGS_NONE by the introspection scanner.

The `/*< nick=none >*/` trigraph attribute is a glib-mkenum thing, and
does not affect the introspection scanner; it would also only affect the
GEnumValue nickname, which is not used by language bindings to resolve
the name of the enumeration member. Plus, GMarkupParseFlags does not
have a corresponding GType anyway.
2022-07-25 22:30:22 +01:00
Simon McVittie
72868c026d gobject/tests/performance: Only run a quick version as installed-tests
ginsttest-runner defaults to timing out each test after 5 minutes,
but gobject/tests/performance/performance.c defaults to running each
of 18 tests for 15 seconds. The result is close enough to 5 minutes
that the setup overhead is enough to make it time out.

We're only running these tests to prove that they still work, not to
get meaningful performance numbers, so cut them down to 1 second per
test-case (the result of which is that performance.c takes about a
minute).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-24 17:34:55 +01:00
Simon McVittie
0714bcb7f4 gobject/tests/performance: Use the other installed-tests template
These are not GTest tests, and don't output TAP.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-24 17:15:47 +01:00
Philip Withnall
55928d6ac0 Merge branch 'more-atomic-ops' into 'main'
Use atomic exchange operations more

See merge request GNOME/glib!2759
2022-07-23 11:35:08 +00:00
Philip Withnall
b33ba73532 Merge branch 'gsignal-threading-cleanup' into 'main'
gsignal: Perform signal unlocked handlers block, unblock and disconnect ops

See merge request GNOME/glib!2823
2022-07-15 21:36:28 +00:00
James Hilliard
d0b9ebbaac meson: fix build without cpp toolchain
We don't need a cpp toolchain for building glib so lets just
automatically disable tests requiring one when not available.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2022-07-15 12:58:41 -06:00
Marco Trevisan (Treviño)
42d52033db gsignal: Do not try to lookup the signal id and work on unlocked node
In g_signal_parse_name we were looking up for the signal from the name
keeping the mutex locked, but we then retrieved and checked the node
data without keeping the lock, so with another thread potentially
changing that.
2022-07-15 16:09:14 +02:00
Marco Trevisan (Treviño)
ae14f3219a gsignal: Perform signal unlocked handlers block, unblock and disconnect ops
We used to perform unneeded lock/unlock dances to perform block, unblock
and disconnect actions, and these were potentially unsafe because we
might have looped in data that could be potentially be changed by other
threads.

We could have also done the same by saving the handlers ids in a
temporary array and eventually remove them, but I don't see a reason for
that since we can just keep all locked without the risk of creating
deadlocks.

Coverity CID: #1474757, #1474771, #1474429
2022-07-15 16:05:35 +02:00
Marco Trevisan (Treviño)
28dc989fc1 gobject/tests: Add test to verify that custom dispatch is called on init
As per this, rename the old test so that it's more in line with the
new one and with what it does.
2022-07-09 00:24:13 +02:00
Marco Trevisan (Treviño)
ed130c8d3b gobject/tests/custom-dispatch: Mark the foo property as explicit-notify
We're calling g_object_notify so let's not make gobject to call it for
us.

This also allows to test that changing a property again doesn't lead to
dispatch properties being called.
2022-07-08 23:54:43 +02:00
Peter Bloomfield
3290ebfadc gobject: Small speedup in weak-ref-set 2022-07-08 14:37:53 +00:00
Matthias Clasen
edcd2d4df4 Add a test for custom dispatch_properties_changed
This tests that we call a custom dispatch_properties_changed,
even in the absence of connected notify handlers. (A recent
optimization broke that and caused a regression in GTK).
2022-07-08 14:03:34 +01:00
Matthias Clasen
c0a618a716 gobject: Don't skip custom dispatch_properties_changed
When I optimized GObject to skip property notification
in some cases, I looked for whether the class has a
custom notify vfunc. I overlooked that that
dispatch_properties_changed can also be customized,
and if it is, we better not skip change notification.

This showed up as breakage in the adjustment tests
in the GTK testsuite.
2022-07-08 13:57:40 +01:00
Philip Withnall
ed564b71dd Merge branch '2672-dataset-tests-and-fixes' into 'main'
gdataset: Preserve destruction order

Closes #2672 and #2676

See merge request GNOME/glib!2776
2022-07-07 11:52:19 +00:00
Philip Withnall
8385f52db7 Merge branch 'inline-macros' into 'main'
gmacros: Provide platform-independent G_ALWAYS_INLINE and G_NO_INLINE

See merge request GNOME/glib!2781
2022-07-06 13:40:10 +00:00
Marco Trevisan (Treviño)
a6f8fe071e cleanup: Replace G_GNUC_NO_INLINE with G_NO_INLINE
As per this we can also now mark G_GNUC_NO_INLINE as
GLIB_AVAILABLE_MACRO_IN_2_58, given that we don't have anymore headers
using it.
2022-07-06 14:57:06 +02:00
Philip Withnall
41691cc4c8 Merge branch 'more-spdx' into 'main'
Add more SPDX license headers

See merge request GNOME/glib!2706
2022-07-05 11:06:49 +00:00
Peter Bloomfield
4ef2025d47 gobject/tests/binding: Add a test with run-dispose
Add tests in which `g_object_run_dispose()` is called on the source or target
of a `GBinding`. After commit a4fa456e67,
the target test caused a failed assertion in `g_weak_ref_set()` that was not
found by the existing tests.  Commit 94ba14d542
weakens the assertion to allow the test to succeed.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-07-04 13:16:21 -04:00
Peter Bloomfield
94ba14d542 gobject: Weaken an assertion in g_weak_ref_set()
When weak references are being cleaned up, it is possible for the `qdata` for
both `quark_weak_locations` and `quark_weak_refs` to have been deallocated,
so that `g_datalist_id_get_data()` returns `NULL` for both. This happens
when `g_object_run_dispose()` is called for the target of a `GBinding`,
and is not an error.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-07-03 14:56:44 -04:00
Emmanuele Bassi
c4f9b926d8 Add versioning to the new macros
They are available in 2.74.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
c0766caf20 Use varargs for enum types definition macros
Makes the syntax a little bit better.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
fa05ebe27c docs: Mention alternatives for defining enumeration types
We should mention glib-mkenums in the documentation for
G_DEFINE_ENUM_TYPE and G_DEFINE_FLAGS_TYPE.

We should also mention the macros in the documentation for glib-mkenums.

This way, developers can choose the most appropriate tool for their use
case.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
6cbf7a7461 Port enums tests to the appropriate assert functions
Do not use `g_assert()` inside tests, as the symbol can be disabled.
Instead, use `g_assert_null()` and `g_assert_nonnull()`.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
2a9ef1e0b4 Test the newly added G_DEFINE macros for enumeration types 2022-06-30 01:46:54 +01:00
Emmanuele Bassi
9a4a10fbc8 Add G_DEFINE macros for enum and flags types
While you might want to use automated tools like glib-mkenums to
generate enumeration types for your library, it's often not entirely
necessary to complicate your build system in order to handle a couple of
enumerations with few values.

Just like we have G_DEFINE macros for object, interface, pointer, and
boxed types, we should provide macros for defining enum and flags types.
2022-06-30 01:46:54 +01:00
Emmanuel Fleury
5699b7b169 Fix some coding style issues in python tests pointed out by black and flake8 2022-06-28 11:19:21 +01:00
Simon McVittie
d4043eced5 Revert "gobject: Use g_datalist_id_remove_multiple"
This reverts commit fa8c7c0 "gobject: Use g_datalist_id_remove_multiple"
(or more specifically the parts of it that were not already reverted
in 01ac1d9 "gobject: Fix crash when disposing a GtkAccelGroup".

Workaround for https://gitlab.gnome.org/GNOME/glib/-/issues/2676

Bug: https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-06-26 18:00:52 +01: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
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
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
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
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
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
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
Philip Withnall
f805635e11 Merge branch 'coverity-signal-emissions' into 'main'
gsignal: Change signal instance ref semantics under static analysis

See merge request GNOME/glib!2762
2022-06-21 12:54:41 +00:00