Commit Graph

2126 Commits

Author SHA1 Message Date
Simon McVittie
a62dd272d8 tests: Test that we can include all headers with an old MAX_VERSION
In principle we could script this so that each max-version.c is compiled
26 times, once per possible MAX_VERSION, but I haven't implemented
that here: just pinning to the oldest possible version is sufficient to
reproduce #2796.

These aren't included in the installed-tests, since they don't really
do anything at runtime (the important thing is that they compile
without warnings).

Reproduces: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 14:50:48 +01:00
Simon McVittie
65016fddd9 Replace all uses of G_VA_COPY with Standard C va_copy
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 18:07:55 +01:00
Xavier Claessens
b8a0ffa1b9 meson: Add missing install tags 2022-10-26 11:55:56 -04:00
sunce
ea1b2cba0c Fix function name typo in comment of gtype.c
The function adjusting private struct size to private struct offset
should be `g_type_class_adjust_private_offset`, instead of the
previously misspelled `g_type_class_add_instance_private` in comment.

Fixes #2791
2022-10-26 10:17:39 +08:00
Marco Trevisan
a3488a38e7 Merge branch 'wip/add-built-headers-deps-v2' into 'main'
meson: Cleanup and fix include files paths, using base path without repetitions

See merge request GNOME/glib!3011
2022-10-25 09:14:15 +00:00
Philip Withnall
7b09713963 Merge branch 'floating-variants-grr' into 'main'
Always ref-sink variants in g_object_set

Closes #2774

See merge request GNOME/glib!2934
2022-10-24 20:21:53 +00:00
Marco Trevisan (Treviño)
836fd0563d meson: Remove unneeded install_tag's on headers
Meson is able to handle this automatically when we're installing in the
include-dir prefix.
2022-10-24 21:09:49 +02:00
Marco Trevisan (Treviño)
6dd222e753 meson: Cleanup include-dir paths, use base path without repetitions
Avoid setting the subdir all the times, just use the global definition
plus the specific module subdir
2022-10-24 21:09:09 +02:00
Matthias Clasen
e79af74d1b gobject: Always ref-sink variants in g_object_set
When collecting varargs, ignore the NOCOPY_CONTENTS
flag for variants. That is what our docs advice for
refcounted types, and it fixes a regression that
was inadvertendly introduced when we stopped doing
some extra GValue copies.

Includes a test case by Philip Withnall.

Fixes: #2774
2022-10-24 10:47:35 +01:00
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