Commit Graph

29410 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
3ec0192970 girepository: Use newer API to create null-terminated ptr array for dependencies
And add a test for this.
2023-12-21 14:14:27 +01:00
Marco Trevisan (Treviño)
2c00c7c924 girepository: Use an array to iterate over and return the search paths
We used to store the search paths into a GSList but this is not
efficient for various reasons, so replace this with an array so that we
can replace return just a GStrv in the public API.
2023-12-21 14:14:27 +01:00
Philip Withnall
833d3fb6cf Merge branch 'file-uri-cleanup' into 'main'
glocalvfs: Remove unnecessary and buggy code

See merge request GNOME/glib!3776
2023-12-21 12:42:27 +00:00
Philip Withnall
385641572d Merge branch '3037-docs-ci' into 'main'
ci: Build docs artifacts for deployment to docs.gtk.org

See merge request GNOME/glib!3768
2023-12-21 12:32:34 +00:00
Michael Catanzaro
af6bf99495 Merge branch 'meson-size_t-check' into 'main'
Fix detecting size_t size when `-Wmissing-prototypes` is in CFLAGS

See merge request GNOME/glib!3777
2023-12-21 12:20:21 +00:00
Philip Withnall
a7de4e3786 Merge branch 'typos' into 'main'
docs: fix a typo

See merge request GNOME/glib!3782
2023-12-21 12:18:48 +00:00
Yegor Yefremov
b969e8fd58 docs: fix a typo
Fix a typo found with codespell.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2023-12-21 07:45:04 +01:00
Thomas Haller
42bd9627a5 gobject: use g_malloc() allocator for GObjectNotifyQueue struct
The GSlice allocator is deprecated. Use g_new0() instead.
2023-12-21 07:26:50 +01:00
Thomas Haller
630d8da211 gobject: remove unused "conditional" argument from g_object_notify_queue_freeze() 2023-12-21 07:26:50 +01:00
Thomas Haller
94c735a2aa gobject: don't freeze to queue notify event in g_object_notify_by_spec_internal()
Previously:

- if the object is currently not frozen, we called
  g_object_notify_queue_freeze() once. Afterwards dispatch the event
  directly. This is probably the common case, and requires one
  notify_lock lock.

- if the object is currently frozen, we call
  g_object_notify_queue_freeze(), g_object_notify_queue_add().
  g_object_notify_queue_thaw().
  This required taking the notify_lock three times.

- if the object is currently not frozen and in_init, then we called
  g_object_notify_queue_freeze(), g_object_notify_queue_freeze(),
  g_object_notify_queue_add(). This also required to take
  the lock three times. There is another thaw at the end of
  object initialization.

That was because we first call g_object_notify_queue_freeze() to see
whether we are frozen. And depending on that, queue the event (and thaw
again).

Instead, g_object_notify_queue_add() can do the check and queueing in
one step. There is no need to call a freeze() to (conditionally) enqueue
a notification. Now only one lock is taken in all cases.

Also, g_object_notify_queue_freeze() and g_object_notify_queue_thaw()
both call g_datalist_id_get_data() (which also take a bit lock). As the
thaw is no longer necessary, the second lock is also saved.
2023-12-21 07:26:50 +01:00
Thomas Haller
a2b467624b gobject: add g_object_notify_queue_create_queue_frozen() helper
This will be used next, and is a separate commit to do a trivial thing
first.
2023-12-21 07:26:50 +01:00
Thomas Haller
9bee14ef3e gobject: avoid taking reference during g_object_thaw_notify()
Before dispatching signals (and calling out to user code), we want to
take a reference and ensure that the object stays alive.

However, a thaw may not decrease the freeze_count to zero, or there may
be no properties to notify. Avoid taking a reference in those cases.
2023-12-21 07:26:50 +01:00
Thomas Haller
95c2150d61 gobject: avoid additional freeze+thaw in g_object_thaw_notify()
It's easy to avoid.
2023-12-21 07:26:50 +01:00
Thomas Haller
f2fafdfe06 gobject: drop ref/unref from g_object_freeze_notify()
This was done since the beginning (commit e773d7dba6 ('fixed dealing
with collection/lcopy of NULL values.'). But it's not clear, why we
would need to take a reference on the calling object.

Freeze does not emit any signals/callbacks and does not call back to the
user. It just sets up some internal state.

This doesn't require to take a reference. The caller must hold a valid
reference to being with, but if that's given, there is no need to
acquire another reference.
2023-12-21 07:26:50 +01:00
Thomas Haller
28331deae2 gobject: adjust assertion for ref-count in g_object_freeze_notify()
g_atomic_int_get() returns a signed int. While we don't expect this to be ever
negative, a negative value would also indicate a bug. Adjust the check to assert
against negative ref-count too.
2023-12-21 07:26:50 +01:00
Marco Trevisan (Treviño)
a8588b803e girepository/tests: Add search paths tests
Add some more tests to ensure search paths behavior follows the expected
one.
2023-12-21 03:02:27 +01:00
Marco Trevisan (Treviño)
2fbe6ca53e cleanup: Add missing final ending line to meson girrepository files 2023-12-21 03:02:27 +01:00
Colomban Wendling
7e9f2dadc6 Fix detecting size_t size when -Wmissing-prototypes is in CFLAGS
As this test includes `-Werror`, we need to be extra careful in which
warnings this code could trigger.
2023-12-20 21:41:33 +01:00
Marco Trevisan (Treviño)
b82d28141d build: Ignore ASAN link order errors when generating typelib files
Without this when compiling GLib with address sanitizer enabled, we'd
end up failing with this error:

  ==375535==ASan runtime does not come first in initial library list;
  you should either link runtime to your application or manually preload
  it with LD_PRELOAD.

Now, given that addressing the fix implies doing more radical changes,
it's just fine here to ignore ASAN to work on tools we use for building
gir files.
2023-12-20 21:35:53 +01:00
Marco Trevisan (Treviño)
083322c0db build: Factorize some common values in gi generation 2023-12-20 21:35:53 +01:00
Marco Trevisan (Treviño)
9c4ff01feb build: Move gir generation to an introspection folder
Generating gir and typelib files has inter-dependencies that may depend
on other elements.

For example, glib requires gobject and gdump generated files require
gmodule, so we've a cyclic dependency because gmodule requires gobject,
that requires glib.

To prevent this, let's just generate the introspection files at once in
a different meson file so that we don't have to deal with this.

As per this we could even revert commit fa37ab6d0 since gio is now
compiled before the gir files.
2023-12-20 21:35:53 +01:00
Marco Trevisan (Treviño)
385ae1b964 gobject: Make GLib-2.0 gir build depend on GObject dependency
GLib gir requires glib-types.h that also includes gobject-visibility.h
that needs to be generated in order to be able to generate the GLib gir,
so explicitly add it to the sources.

Also, in order to link the typelib we need the definitions of the *_get_type()
functions that are defined in the gboxed.c file, so this should be part
of the gir sources or we'll have linking issues.
2023-12-20 21:35:53 +01:00
Marco Trevisan (Treviño)
cd8f511262 girepository: Return enumerated versions as a GStrv
Returning list of strings is a bad idea, so let's do not now since
we're exposing the API for the first time.
2023-12-20 21:02:48 +01:00
Colomban Wendling
1fa03292c1 glocalvfs: Remove unnecessary and buggy code
The code for stripping the query and fragment from file:// URIs was
wrong, as it would not properly strip a query if there was a fragment.

Fortunately, that code was actually useless, as the "stripped URI" was
passed to g_filename_from_uri() that does proper stripping itself.

So simply drop this extra unnecessary stripping logic from GLocalVFS's
get_file_for_uri() and let g_filename_from_uri() do all the work.
2023-12-20 19:25:50 +01:00
Colomban Wendling
5790ce14e8 tests: Test file:// URIs with both query and fragment 2023-12-20 19:23:40 +01:00
Philip Withnall
30d6e911c4 Merge branch 'gtask-return-literal' into 'main'
gtask: Add g_task_return_new_error_literal()

See merge request GNOME/glib!3771
2023-12-20 16:53:20 +00:00
Marco Trevisan (Treviño)
81068e5c00 gio: Use g_task_return_error_literal() where we don't need formatting 2023-12-20 16:14:57 +00:00
Marco Trevisan (Treviño)
7c71090723 gtask: Add g_task_return_new_error_literal()
Avoids going through the formatting function or nesting GError calls.
2023-12-20 16:14:57 +00:00
Philip Withnall
43c83142a9 Merge branch 'datetime-usec' into 'main'
GDateTime: Add usec precision API for unix time

See merge request GNOME/glib!3770
2023-12-20 15:50:56 +00:00
Xavier Claessens
a4edf1e3ae GDateTime: Add usec precision API for unix time 2023-12-20 07:48:10 -05:00
Philip Withnall
35c21681c1 Merge branch 'ebassi/girepository-no-gio' into 'main'
girepository: Drop libgio dependency from gdump.c

See merge request GNOME/glib!3763
2023-12-20 00:42:59 +00:00
Emmanuele Bassi
4a270c947c tests: Check thread safety of GParamSpecPool
Aside from checking that we're accessing the global GParamSpecPool
without necessarily initializing GObjectClass, we should also verify
that we're doing so safely without the class init lock.
2023-12-19 22:48:03 +00:00
Emmanuele Bassi
62477118e7 tests: Verify GParamSpecPool creation
Ensure that the fix in commit af024b6d7e7d3fbef23c1f7d1f7704fc90ac4fb1
works, by replicating what gobject-introspection does:

- initialise the default GTypeInterface from a GType without also
  initialising GObjectClass
  - install a property for the interface
- find the GParamSpec using g_object_interface_find_property()
2023-12-19 19:53:48 +00:00
Emmanuele Bassi
540ba432fb tests: Add unit for GParamSpecPool
Check that the API contract is respected, even though nobody should be
using GParamSpecPool to implement properties outside of GObject.
2023-12-19 19:53:48 +00:00
Emmanuele Bassi
fc5f986e60 Initialise the global GParamSpecPool in more places
Right now, we're assuming that GObjectClass will be initialised first
and under a lock, but that's not always the case: when traversing a list
of type, the first one might be a GTypeInterface, and if we initialise
an interface that installs a property, the whole thing comes crashing
down because the global GParamSpecPool is not initialised.

Instead of taking a lock everywhere, we can use an atomic compare and
swap; the first thread that installs a property wins the race, as any
other access to the GParamSpecPool is performed under a lock.
2023-12-19 19:53:48 +00:00
Marco Trevisan (Treviño)
f08609b169 gio/tests/task: Use wait_for_completed_notification() to wait for task 2023-12-19 20:29:44 +01:00
Emmanuele Bassi
8ce40ac590 Add destructor for GParamSpecPool
While GParamSpecPool should never be used by newly written code, having
the ability to free the associated memory is a good idea. The only
reason why this hasn't been necessary until now is that we assume base
classes are going to keep their GParamSpecPool around forever.
2023-12-19 18:41:02 +00:00
Philip Withnall
989f87d26a build: Ensure gi-visibility.h is built before libgirepository_dep is used
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-19 18:41:02 +00:00
Philip Withnall
fa37ab6d06 girepository: Drop libgio dependency from gdump.c
It’s not particularly necessary, and makes the build-time dependencies
more complex than they need to be, as it means that to generate
GLib-2.0.gir and GObject-2.0.gir, libgio.so (and its generated headers)
already needs to have been built.

See discussion on https://gitlab.gnome.org/GNOME/glib/-/issues/3164

These changes need to be replicated in gobject-introspection.git before
the problem can be solved, though, as that still has its own copy of
`gdump.c` (which it installs and uses).

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

Helps: #3164
2023-12-19 18:41:02 +00:00
Marco Trevisan (Treviño)
39f820e507 gio/tests/task: Also check for formatted error messages 2023-12-19 18:55:29 +01:00
Philip Withnall
0e475a6e11 Merge branch '3155-girepository-docs-cleanups' into 'main'
girepository: Port documentation to gi-docgen and update

See merge request GNOME/glib!3767
2023-12-18 16:58:40 +00:00
Philip Withnall
25f662bdc3 ci: Add missing SPDX header to check-missing-install-tag.py
Using the git history.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:56:40 +00:00
Philip Withnall
6826d21743 ci: Ensure man pages are built alongside docs
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-12-18 14:52:39 +00:00
Philip Withnall
9ea0b6edf5 docs: Set install_tag on man pages
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-12-18 14:52:39 +00:00
Philip Withnall
5cf7af694a ci: Update docs build for the release job
Not that this job is particularly maintained at the moment, but at least
try to keep it up to date.

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

Helps: #3037
2023-12-18 14:43:36 +00:00
Philip Withnall
2a1be27431 ci: Run the fedora CI job on merges as well as branches
Since it now has to build the docs (and code coverage) for `main`, that
needs to happen after branches are merged.

Other jobs remain not-run on merges.

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

Helps: #3037
2023-12-18 14:43:36 +00:00
Philip Withnall
5400094ab0 ci: Build docs artifacts for deployment to docs.gtk.org
The actual deployment will be done by
https://gitlab.gnome.org/GNOME/gtk/-/blob/docs-gtk-org/; it pulls the
most recent artifact zip from glib.git.

This ensures that only one project/job/branch has push access to the
website.

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

Helps: #3037
2023-12-18 14:43:36 +00:00
Philip Withnall
9b915507af Merge branch 'ebassi/socket-bytes' into 'main'
Add GBytes variants for GSocket receive methods

See merge request GNOME/glib!3603
2023-12-18 14:40:00 +00:00
Michael Catanzaro
bfa615616f Merge branch 'signals-doc' into 'main'
gsignal: fix reference to signals documentation page

See merge request GNOME/glib!3764
2023-12-18 14:32:09 +00:00
Philip Withnall
98e4b3adec tests: Add tests for g_socket_receive_bytes() and g_socket_receive_bytes_from()
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00