Commit Graph

28901 Commits

Author SHA1 Message Date
Philip Withnall
aed9098530 girepository: Fix various leaks in cmph-bdz-test
See https://gitlab.gnome.org/GNOME/glib/-/jobs/3294034

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-14 11:00:01 +00:00
Philip Withnall
af30e69140 Merge branch 'wip/oholy/gcontenttype-make-valid' into 'main'
gcontenttype: Make filename valid utf-8 string before processing

Closes #3168

See merge request GNOME/glib!3700
2023-11-13 12:14:01 +00:00
Ondrej Holy
30e102518a gcontenttype: Make filename valid utf-8 string before processing
The `g_content_type_guess_for_tree` function segfaults currently when
processing filenames that are not valid unicode strings. Let's use the
`g_filename_to_utf8` and `g_utf8_make_valid` functions before other
processing to prevent that.

Let's also add a test for it to avoid this in future.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3168
2023-11-13 12:14:01 +00:00
Philip Withnall
b50a8a69d9 Merge branch 'th/prgname' into 'main'
[th/prgname] use atomic pointers for g_prgname/g_application_name and add g_set_prgname_once()

See merge request GNOME/glib!3699
2023-11-13 11:47:44 +00:00
Emmanuele Bassi
4144341e7a Merge branch '3155-cleanups-renames' into 'main'
girepository: Rename symbols to the GI namespace

See merge request GNOME/glib!3704
2023-11-08 17:56:43 +00:00
Thomas Haller
7098250e7a gutils: avoid race setting prgname from g_option_context_parse()/g_application_run()
g_option_context_parse()/g_application_run()/g_test_init() for
convenience also call g_set_prgname(), when the prgname is unset at this
point. This was racy.

Fix the race by using an atomic compare-and-exchange and only reset the
value, if it is unset still.
2023-11-08 16:36:14 +01:00
Thomas Haller
54e0b2d75b gutils: use atomic pointers for g_application_name
The mutex is not necessary to guard a single pointer.
2023-11-08 16:36:14 +01:00
Thomas Haller
0d61895ef1 gutils: assert against calling g_set_application_name()
g_set_application_name() guards against being reset, but it doesn't
remember whether it was set, it only checks whether g_application_name
was set to non-NULL. When allowing g_set_application_name(NULL) that leads
to odd behaviors, like:

    g_set_application_name(NULL);
    g_set_application_name("foo");

would not warn.

Disallow that and assert against a NULL application_name.

Note that application_name argument is also not marked as "(nullable)".
2023-11-08 16:36:14 +01:00
Thomas Haller
167deee94d gutils: use atomic pointers for g_prgname
The mutex is not necessary to guard a single pointer.
2023-11-08 16:36:14 +01:00
Philip Withnall
74502f51a6 Merge branch 'mime-type-leak' into 'main'
glib.supp: Suppress the global_mime_dirs allocations

See merge request GNOME/glib!3702
2023-11-08 15:24:39 +00:00
Philip Withnall
2b544c3f66 girepository: Remove _ prefix from private functions
Now that libgirepository uses `GI_AVAILABLE_IN_*` macros, that’s what
controls symbol visibility. The `_` prefixes are redundant, and out of
keeping with the rest of GLib.

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

Helps: #3155
2023-11-08 15:23:31 +00:00
Philip Withnall
7b029e564d girepository: Remove redundant GLib version checks
Now that libgirepository is inside glib.git, it’s guaranteed access to
all the latest APIs, so there’s no need for version checks.

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

Helps: #3155
2023-11-08 15:06:21 +00:00
Philip Withnall
b32da06a7c girepository: Rename symbols to the GI namespace
Rather than a mix of structs being in `GI` and their methods being in
`g_`.

We’ve chosen not to use the `g_` namespace because a number of the
libgirepository class names are quite generic, so we’d end up with
confusing symbols like `GScopeType` and `GArgument`.

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

Helps: #3155
2023-11-08 15:05:20 +00:00
Philip Withnall
f4db8af9de gitypeinfo: Remove deprecated API
It’s not needed after a major version bump.

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

Helps: #3155
2023-11-08 15:05:20 +00:00
Philip Withnall
9c10f3ec02 girepository: Remove backwards compatibility symbol renames
After bumping the major version number, we don’t need backwards
compatibility any more.

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

Helps: #3155
2023-11-08 12:52:23 +00:00
Philip Withnall
2787a86693 Merge branch 'ebassi/girepository' into 'main'
Move libgirepository into GLib

Closes #455, #457, #49, #13, #318, #298, #38, #200, #96, #244, #175, and #218

See merge request GNOME/glib!3642
2023-11-08 12:24:03 +00:00
Emmanuele Bassi
ebb0346380 gir: Do not include builtin directories in pkgconfig.generate()
It's deprecated since Meson 0.62, and breaks the build with fatal
warnings enabled for Meson.
2023-11-08 12:04:12 +00:00
Philip Withnall
342b654e35 Merge branch 'main' into 'ebassi/girepository'
This needs to be done as a merge rather than a rebase because !3642 cannot be rebased.

Conflicts:
  meson_options.txt
2023-11-08 11:54:28 +00:00
Philip Withnall
8f36997aaa Merge branch 'wip/pwithnall/macos-gio-tool-fix' into 'main'
tests: Fix gio-tool.py test on macOS

See merge request GNOME/glib!3701
2023-11-08 11:26:27 +00:00
Philip Withnall
31906961d1 glib.supp: Suppress the global_mime_dirs allocations
These are one-time allocations which are still reachable at the end of
the process. They cause warnings like this in valgrind:
```
==14408== 128 bytes in 1 blocks are definitely lost in loss record 1,287 of 1,403
==14408==    at 0x4847A40: realloc (vg_replace_malloc.c:1649)
==14408==    by 0x48CCD6E: g_realloc (gmem.c:201)
==14408==    by 0x48F4CB1: g_string_expand (gstring.c:82)
==14408==    by 0x48F4D59: g_string_sized_new (gstring.c:113)
==14408==    by 0x48F4D91: g_string_new (gstring.c:134)
==14408==    by 0x48A5805: g_build_path_va (gfileutils.c:1929)
==14408==    by 0x48A62D1: g_build_filename_va (gfileutils.c:2222)
==14408==    by 0x48A63FE: g_build_filename (gfileutils.c:2316)
==14408==    by 0x491CD89: g_build_user_data_dir (gutils.c:1879)
==14408==    by 0x491CDCF: g_get_user_data_dir (gutils.c:1920)
==14408==    by 0x4B51E53: _g_content_type_set_mime_dirs_locked (gcontenttype.c:145)
==14408==    by 0x4B51F33: g_content_type_set_mime_dirs (gcontenttype.c:194)
==14408==    by 0x40C222: main (desktop-app-info.c:1880)
```

For example in https://gitlab.gnome.org/GNOME/glib/-/jobs/3278564

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-08 11:03:58 +00:00
Philip Withnall
d59bac3f32 tests: Fix gio-tool.py test on macOS
Content types are different on macOS.

This fixes commit 9028c9bdf.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3158
2023-11-08 10:29:43 +00:00
Emmanuele Bassi
db5c42fad0 gir: Rename gir_writer_write()
Use g_ir_writer_write(), as a dual of g_ir_parser_parse_*().

Also, don't abuse C++ reserved keywords for argument names.
2023-11-08 00:23:35 +00:00
Emmanuele Bassi
9a6c518d31 gir: Rename girwriter.h to girwriter-private.h
It's a private header.
2023-11-08 00:16:58 +00:00
Emmanuele Bassi
b0f4a6bcc4 gir: Rename girnode.h to girnode-private.h
It's a private header.
2023-11-08 00:09:04 +00:00
Emmanuele Bassi
f9580e90c4 gir: Rename girparser.h to girparser-private.h
It's a private header.
2023-11-08 00:07:11 +00:00
Emmanuele Bassi
48984375dc gir: Rename girmodule.h to girmodule-private.h
It's private header.
2023-11-08 00:06:01 +00:00
Emmanuele Bassi
51f518e749 Replace GI_AVAILABLE_IN_2_* with GI_AVAILABLE_IN_ALL
This is the first release of GIRepository 2.0.
2023-11-08 00:02:12 +00:00
Emmanuele Bassi
ba24fc659d Remove deprecated API
There's no point in releasing a new library with deprecated API.
2023-11-07 23:57:18 +00:00
Emmanuele Bassi
b3dfaf5e97 gir: Use pragma once for the inclusion guard 2023-11-07 18:23:17 +00:00
Emmanuele Bassi
85d93fb581 Merge branch 'codegen-deps-fixes' into 'main'
meson: Add missing dependencies for utility files for gdbus-codegen

See merge request GNOME/glib!3689
2023-11-07 15:21:27 +00:00
Philip Withnall
e87f8e9c5a Merge branch '3158-info-critical' into 'main'
gio-tool-info: Fix critical warning when --attributes are specified and add basic unit tests

Closes #3158

See merge request GNOME/glib!3684
2023-11-07 14:37:11 +00:00
Philip Withnall
9028c9bdf3 gio-tool-info: Fix critical warning when --attributes are specified
When `--attributes` is specified and doesn’t include `standard::name` in
its list, `gio` would print a critical warning from the (mandatory) call
to `g_file_info_get_name()`.

Fix that by making the call to `g_file_info_get_name()` optional.

Add a unit test too.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3158
2023-11-07 13:51:56 +00:00
Philip Withnall
3e0a99a059 tests: Add a very basic test suite for gio-tool
It gives nowhere near full coverage, but it’s something we can build on
in future.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3158
Helps: #2950
2023-11-07 13:51:56 +00:00
Philip Withnall
077104e63b tests: Run processes under test with G_DEBUG=fatal-warnings
Modify all the similar Python test wrappers to set
`G_DEBUG=fatal-warnings` in the environment of the program being tested,
so we can catch unexpected warnings/criticals.

Adding this because I noticed it was missing, not because I noticed a
warning/critical was being ignored.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
120e0ee649 tests: Set a default timeout value for GIO Python tests
Otherwise every test has to set one explicitly, which is a bit tedious.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
96ee1ea086 gio-tool: Print help output to stdout when --help is passed
If the help output is explicitly requested by the user, it’s
conventional for it to be printed to stdout rather than stderr.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
7c97b93837 gio-tool: Factor out repetitive lists of subcommands
Store their details in an array which can be iterated over instead.

This introduces no functional changes, just a cleanup which will allow
following commits to be neater.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
c17090275c Merge branch 'th/main-sources-dict-as-set' into 'main'
gmain: optimize "context->sources" hash table to use as set

See merge request GNOME/glib!3664
2023-11-06 15:05:43 +00:00
Philip Withnall
a766945766 Merge branch 'main' into 'main'
fix: about libproc.h and PROC_PIDLISTFD_SIZE

See merge request GNOME/glib!3687
2023-11-06 14:46:52 +00:00
CaiJingLong
7b80f73d29 fix: about libproc.h and PROC_PIDLISTFD_SIZE 2023-11-06 14:46:52 +00:00
Philip Withnall
113063e413 Merge branch 'socket-ready-fixes' into 'main'
Socket & readiness fixes

See merge request GNOME/glib!3668
2023-11-06 14:35:23 +00:00
Philip Withnall
534edd070d Merge branch '2810-thread-pool-slow' into 'main'
tests: Fix a race in thread-pool-slow

Closes #2810

See merge request GNOME/glib!3694
2023-11-06 14:18:20 +00:00
Sergey Bugaev
a3d02ad565 gmain: Correct g_source_get_ready_time () doc
Mention that ready time being equal to the current time means the source
will fire immediately.

Related to https://gitlab.gnome.org/GNOME/glib/-/issues/3148

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:14:07 +03:00
Sergey Bugaev
150965a9b3 gsocket: Fix detecting timeouts
If she socket is dispatched at exactly the previously set ready time,
it should already be considered to have timed out. This can easily
happen in practice when using a low resolution timer.

This fixes a test failure on GNU/Hurd, see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:14:02 +03:00
Sergey Bugaev
6b7b211338 gio: Add G_IO_ERROR_DESTINATION_UNSET
...and map EDESTADDRREQ to it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:04:01 +03:00
Thomas Haller
b067c43b00 gmain: optimize "context->sources" hash table to use as set
Instead of tracking a "(guint,GSource*)" tuple in the "context->sources"
dictionary, only track pointers to the "source_id".

With this we use the GHashTable as Set (g_hash_table_add()), which is
optimized and avoids storing a separate value array.

It's simple enough to do, because there are literally 5 references to
"context->sources". It's easy to review those usages and reason that the
handling is correct.

While at it, in g_main_context_find_source_by_id() move the check for
SOURCE_DESTROYED() inside the lock. It's not obvious that doing this
without a lock was correct in every case. But doing the check with
a lock should be fast enough to not worry about whether it's absolutely
necessary.
2023-11-06 08:48:12 +01:00
Thomas Haller
501bdb51e4 glib: add internal G_CONTAINER_OF() macro
"container_of()" is a popular macro that works together with
G_STRUCT_OFFSET()/offsetof().

For internal use only.
2023-11-06 08:48:12 +01:00
Thomas Haller
3c09257ea1 glib: add internal g_uint_hash()/g_uint_equal()
We have g_int_hash()/g_int_equal(), which in practice might also work
with with pointers to unsigned integers. However, according to strict
interpretation of C, I think it is not valid to conflate the two.

Even if it were valid in all cases that we want to support, we should
still have separate g_uint_{hash,equal} functions (e.g. by just #define
them to their underlying g_int_{hash,equal} implementations).

Add instead internal hash/equal functions for guint.
2023-11-06 08:48:12 +01:00
Philip Withnall
734f8184e8 Merge branch 'gvalue-steal-string' into 'main'
gvalue: add "steal_string"

See merge request GNOME/glib!3695
2023-11-04 11:05:47 +00:00
Alexander Slobodeniuk
7880d87091 gvalue: add g_value_steal_string()
This call is needed to avoid an extra copy after
serialization of the data.
2023-11-04 10:40:30 +00:00