Commit Graph

2117 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
341895a19e glib, gmodule, gobject: Add generated headers to the lib dependency
This requires changing them from being generated sources at compile time
to custom targets, but it also ensures that they are actually there when
needed, in fact currently we may instead try to compile files that requires
them without having been generated yet.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2346914 (glib)
See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2344802 (gmodule)
See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2345205 (gobject)
2022-10-23 18:04:56 +02:00
Marco Trevisan
e49c4b1a9e Merge branch 'python-code-style-again' into 'main'
tests: Fix code style in Python files to satisfy black and flake8

See merge request GNOME/glib!2984
2022-10-20 11:59:53 +00:00
Marco Trevisan (Treviño)
476e33c3f3 gio, glib: Use G_OS_DARWIN for code that is for such environments
While we preserved the COCOA/CARBON cases when specific libraries are
needed.
2022-10-20 03:37:21 +02:00
Philip Withnall
59541e335a tests: Fix code style in Python files to satisfy black and flake8
This should make the style-check-diff CI job happy again.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-19 12:28:08 +01:00
Philip Withnall
ab774d6e8b gbinding: Explicitly ignore return values from g_param_value_validate()
They only indicate whether the value had to be modified to keep it
valid. That doesn’t matter when binding values.

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

Coverity CID: #1498116, #1498114
2022-10-18 15:12:31 +01:00
Michael Catanzaro
8c54de8fa0 Fix build when G_DISABLE_CAST_CHECKS is defined to empty string
The usual use of G_DISABLE_CAST_CHECKS is to define it without giving it
a value. The value was never looked at until
f946e45a0c, where I decided it would be
cool to ignore it if defined to 0. But this broke the original usage, so
we need to revert that.

I thought it would be a good idea to look at the value in order to give
applications an off switch for the new behavior, so you could continue
to build optimized builds with cast checks enabled. We could still try
to find a way to do that in the future if desired, e.g. by introducing a
new G_ENABLE_CAST_CHECKS definition. But this doesn't seem especially
important. G_DISABLE_CAST_CHECKS is not documented anyway, so how we
handle cast checks is entirely up to GLib.
2022-10-18 13:58:14 +01:00
Philip Withnall
292c117b98 Merge branch 'w32-tests' into 'main'
Various win32 test fixes

See merge request GNOME/glib!2952
2022-10-17 09:53:44 +00:00
Marc-André Lureau
8c0fa77a71 tests/gobject-query.py: make it work on msys2/win32
For unclear reasons, universal_newlines=True doesn't seem to set the
text encoding correctly. Even if I set only encoding='utf-8', the test
fails. The combination here works for me, \o/.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:53 +04:00
Marc-André Lureau
fdfe94fb16 tests/gobject-query: it is not a script (anymore?)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:51 +04:00
Philip Withnall
4bc284fca6 Merge branch 'wip/smcv/deprecated-prop-followup' into 'main'
Run tests with G_ENABLE_DIAGNOSTIC=1

See merge request GNOME/glib!2889
2022-10-15 21:31:29 +00:00
Philip Withnall
9daa0b60c0 Merge branch 'ebassi/object-allocator' into 'main'
Use the system allocator on UNIX when creating GTypeInstances

See merge request GNOME/glib!2799
2022-10-15 20:20:26 +00:00
Marco Trevisan (Treviño)
60c935a9c4 gboxed: Add GBookmarkFile as Boxed types
Now that we've a copy function we can define it as a boxed type, making
it fully introspectable.
2022-10-14 16:40:56 +01:00
Philip Withnall
f946e45a0c Merge branch 'mcatanzaro/cast-checks' into 'main'
Automatically disable cast checks when building with optimization

See merge request GNOME/glib!2850
2022-10-14 15:26:35 +00:00
Xavier Claessens
e5565f6635 Rename all visibility macros 2022-10-13 20:53:56 -04:00
Xavier Claessens
dcfc9f689e Fix symbol visibility macros on Windows
There is currently no `dllimport` attribute on any of our function,
which prevents MSVC to optimize function calls.

To fix that issue, we need to redeclare all our visibility macros for
each of our libraries, because when compiling e.g. GIO code, we need
dllimport in GLIB headers and dllexport in GIO headers. That means they
cannot use the same GLIB_AVAILABLE_* macro.

Since that's a lot of boilerplate to copy/paste after each version bump,
this MR generate all those macros using a python script.

Also simplify the meson side by using `gnu_symbol_visibility : 'hidden'`
keyword argument instead of passing the cflag manually.

This leaves only API index to add manually into glib-docs.xml when
bumping GLib version. That file cannot be generated because Meson does
not allow passing a buit file to gnome.gtkdoc()'s main_xml kwarg
unfortunately.
2022-10-13 20:53:56 -04:00
Philip Withnall
350b92821c Merge branch 'wip/smcv/deprecated-construct-prop' into 'main'
gobject: Only emit deprecation warnings for user-specified properties

Closes #2748

See merge request GNOME/glib!2912
2022-10-12 13:56:46 +00:00
Philip Withnall
e90733a457 Merge branch 'atomic-older-cplusplus' into 'main'
gatomic: fix the atomic compare_and_exchange macros on older C++ standard versions

See merge request GNOME/glib!2864
2022-10-12 09:56:19 +00:00
Marco Trevisan (Treviño)
80cf66034b gobject/tests/param: Add unit test for handling invalid NULL param spec
This was fixed by !2921 but there was no test with the MR, so add one.
2022-10-10 21:01:10 +02:00
Emmanuele Bassi
3b7af4dd5d gtype: Use the system allocator on UNIX
Instead of replacing the slice allocator wholesale, we can start phasing
it out by having GTypeInstance use the system allocator on operating
systems where we can assume good performance profiles.

We cannot commit to fully gutting GSlice in the cases where we might
still need it, like the G(S)List allocator and small, similarly-sized
data structures.

The main user of GSlice is still GTypeInstance/GObject, and those have
moved out of the sweet spot of GSlice's performance envelove over the
years, with larger instance sizes and private data.

See: #1079
2022-10-07 15:54:11 +01:00
Emmanuele Bassi
ea3f17d598 Empty values are not valid GParamSpec
The validate() vfunc for GParamSpecParam returns FALSE for empty GValue,
which means the is_valid() vfunc should do the same.

This avoids a segfault when calling g_param_value_is_valid() on a
GParamSpecParam.

Fixes: #2770
2022-09-25 14:20:24 +01:00
Simon McVittie
7254fd7aa3 gobject/tests: Don't unref a floating object reference by mistake
This goes undiagnosed under normal circumstances, but is a critical
warning (which is fatal by default) under G_ENABLE_DIAGNOSTIC. This is a
programming error, so we should only exercise it under
g_test_undefined(), and only in a test that is intentionally doing this
(as in the previous commit).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 11:19:52 +01:00
Simon McVittie
0bba27eea9 gobject/tests: Exercise a floating object reaching last-unref
This was previously exercised (probably by mistake) in
gobject/tests/type.c, but without making any assertions about what
happened, and the test would fail under G_ENABLE_DIAGNOSTIC if GLib was
compiled with debug enabled.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 11:19:41 +01:00
Simon McVittie
88e160dfe4 tests: Move common test environment variables to top level
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 11:19:28 +01:00
Marco Trevisan
87b4771d1f Merge branch 'install-tag-2' into 'main'
meson: Set install_tag remaining installed files

See merge request GNOME/glib!2905
2022-09-21 10:05:18 +00:00
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
Xavier Claessens
a73ca336aa meson: Set install_tag on remaining installed files 2022-09-20 11:30:12 -04:00
Xavier Claessens
49fd523af3 meson: Set install_tag on systemtap files
This could be done automatically by Meson, this commit can be reverted
when we have that Meson PR in our CI:
https://github.com/mesonbuild/meson/pull/10829
2022-09-20 11:30:02 -04:00
Xavier Claessens
c00df192ee meson: Set install_tag on installed tests files
This could be done automatically by Meson, this commit can be reverted
when we have that Meson PR in our CI:
https://github.com/mesonbuild/meson/pull/10829
2022-09-20 11:30:02 -04: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
Marco Trevisan (Treviño)
1cbe7a6734 meson: Build C++ tests for the currently supported C++ standard versions
We've various macros definitions that are depending using C++ features
that may not work in all the standard versions, so recompile the cxx
tests that we have in all the ones we want to support.
2022-09-15 01:18:40 +02: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
Michael Catanzaro
b8e1ecdd6b Automatically disable cast checks when building with optimization
Cast checks are slow. We seem to have some rough consensus that they are
important for debug builds, but not for release builds. Problem is, very
few apps define G_DISABLE_CAST_CHECKS for release builds. Worse, it's
undocumented, so there's no way apps could even be expected to know
about it.

We can get the right default is almost all situations by making this
depend on the __OPTIMIZE__ preprocessor definition. This is a GCC-specific
thing, although Clang supports it too. If the compiler does not define
__OPTIMIZE__, then this commit does no harm: you can still use
G_DISABLE_CAST_CHECKS as before. When checking __OPTIMIZE__, we are
supposed to ensure our code has the same behavior as it would if we do
not, which will be true except in case the check fails (which is
programmer error).

Downside: this will not automatically do the right thing with -Og,
because __OPTIMIZE__ is always defined to 1. We don't want to disable
cast checks automatically if using -O0 or -Og. There's no way to
automatically fix this, but we can create an escape hatch by allowing
you to define G_DISABLE_CAST_CHECKS=0 to force-enable cast checks. In
practice, I don't think this matters much because -Og kinda failed:
GCC's man page says it should be a superior debugging experience to -O0,
but it optimizes variables away so it's definitely not.

Another downside: this is bad if you really *do* want cast checks in
release builds. The same solution applies: define
G_DISABLE_CAST_CHECKS=0 and you'll get your cast checks.
2022-08-03 16:18:17 -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