Commit Graph

28094 Commits

Author SHA1 Message Date
Luca Bacci
85e21ff757 tests/constructor: Test all destructors
Previously we were only testing destructors that run on
dlclose, now we also test destructors running at application
exit.
2023-10-03 11:07:11 +02:00
Philip Withnall
57169dd92f Merge branch 'update-gtimer-annotations' into 'main'
Update GTimer annotations

See merge request GNOME/glib!3573
2023-10-03 08:46:20 +00:00
Christian Hergert
ab2fe494a4 gobject: inline G_TYPE_IS() macros within gtype.c
If you take a release build (--buildtype=release) previously of GLib,
functions such as g_type_create_instance() would call out to
g_type_test_flags() which you can see by disassembling and looking for the
call instruction to <g_type_test_flags> via the library ABI.

Now that the previous commit allows checking abstract and deprecated flags
it makes sense to let the compiler optimize those checks into a single
pass. This is only possible if the functions themselves are inlined.

Additionally, any time we have the same TypeNode we would want to be able
to reuse that node rather than re-locate it.
2023-10-03 09:44:32 +01:00
Christian Hergert
5de7dd5a4b gobject: cache flags needed for g_type_create_instance()
Every call to g_type_create_instance() currently will incur a RWLock at
least once, but usually twice to test for both G_TYPE_FLAG_ABSTRACT and
G_TYPE_FLAG_DEPRECATED.

Additionally, each call to g_type_instance_free() also checks for these.
That results in a synchronization of GTypeInstance creation across all
threads as well as being a huge amount of overhead when creating instances
like GskRenderNode.

With this patch in place, the next two biggest issues are
g_type_class_ref() and g_type_test_flags() not getting inlined within
gtype.c in release builds. We can address that separately though.

Sysprof shows that the RWLock, with this patch in place, falls off the
profiles.
2023-10-03 09:44:32 +01:00
Philip Withnall
8adc39a870 Merge branch 'update-goption-annotations' into 'main'
Update GOptionContext annotations

See merge request GNOME/glib!3568
2023-10-03 08:43:54 +00:00
Philip Withnall
83eb8fc359 Merge branch 'wip/chergert/separate-gweakref-from-gweaknotify-gdata' into 'main'
gobject: Separate GWeakRef from GWeakNotify

See merge request GNOME/glib!3316
2023-10-03 08:43:37 +00:00
Luca Bacci
f23a31ee26 Use helper shared library for the constructor test 2023-10-03 10:43:34 +02:00
Philip Withnall
a9f2ffe788 Merge branch 'new_datetime_mods' into 'main'
Add support for case modifiers to DateTime

Closes #3115

See merge request GNOME/glib!3584
2023-10-03 08:43:03 +00:00
Rick Calixte
0b114b2687 Add support for case modifiers to DateTime 2023-10-03 08:43:03 +00:00
Philip Withnall
74d2586d7c Merge branch 'prefix_match_more_prominence' into 'main'
GDesktopAppInfo: prioritize match_type over match_category when searching apps

Closes #3082

See merge request GNOME/glib!3592
2023-10-03 08:40:14 +00:00
Luca Bacci
683991d836 Add test for module constructors, destructors and TLS callbacks 2023-10-03 10:33:42 +02:00
Lukáš Tyrychtr
0e8e941e95 glocalfileinfo: Preserve microseconds for access/modify times
When setting the file time using utimensat, don't ignore
microseconds for access/modify times. By doing that, they're preserved
when using g_file_info_set_modification_date_time and then setting the file's
attributes from it.

Fixes #3116
2023-10-03 09:32:44 +01:00
Luca Bacci
af0a9489e7 Docs: Static builds on MSVC are supported 2023-10-03 10:26:10 +02:00
Luca Bacci
0bbe3c8447 gconstructorprivate.h: Add seamless support for C++
G_DEFINE_TLS_CALLBACK could be made public in the future
2023-10-03 10:26:10 +02:00
Luca Bacci
f916621d72 gthread-win32: Clean up GPrivate data in all cases 2023-10-03 10:26:10 +02:00
Luca Bacci
8436785a5f Make use of TLS callbacks for static builds on Windows
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/3087
2023-10-03 10:26:10 +02:00
Luca Bacci
51cbb63cd5 Add support for TLS callbacks on Windows 2023-10-03 10:25:06 +02:00
Philip Withnall
ec8c62d765 Merge branch 'gresources-msvc-prototypes' into 'main'
gconstructor.h: Ensure [c|d]tor prototypes are present for MSVC

See merge request GNOME/glib!3589
2023-10-03 08:15:43 +00:00
Michael Catanzaro
61075ef0bd Expand security policy to cover previous stable branch
The goal here is to reconcile the difference between GLib's 6-month
security policy and GNOME's 12-month policy (which may soon be expanded
to 13 months, gnome-build-meta#731). It's strange for GLib to be an
exception when the rest of GNOME supports two stable branches at a time.
I'm not aware of any other GNOME project with a shorter release lifetime
than GNOME itself, and it results in a situation where the previous
stable version of the GNOME runtime never receives any GLib updates,
since we stick with the same GLib version for the entire release and do
not do security backports.

But I also want to avoid creating an expectation that GLib maintainers
will do a bunch of additional backporting work, so most commits should
be out of scope. We can say maintainer discretion will be used to
determine whether a backport to the previous stable branch is warranted.
And normally, it won't be, so the goal should be no previous stable
branch releases. But occasionally we might feel a CVE is important
enough that a release really is warranted.
2023-10-03 09:12:37 +01:00
Nelson Benítez León
40f567aa2a GDesktopAppInfo: prioritize match_type over match_category when searching apps
Commit 9e2ad88455 improved app search results by allowing to differentiate
their match_type: prefix match or substring match; while giving more priority
to prefix matches over substring matches, but only when they are in the same
match_category[1].

This was a step forward but, as outlined in #3082, still not enough to get
most relevant results first to the user, because apparently (and for the
specific case of desktop app searching) a prefix match in a lower category
is more relevant to the user than a substring match in a higher category.

So that's what this commit implements, i.e. it makes sure prefix matches
are still preferred over substring matches but this time not only when
in the same category but also across different categories.

[1] Match category is the Desktop file key where the match happened.
    They are shown below from top to lesser priority.
      DESKTOP_KEY_Name
      DESKTOP_KEY_Exec
      DESKTOP_KEY_Keywords
      DESKTOP_KEY_GenericName
      DESKTOP_KEY_X_GNOME_FullName
      DESKTOP_KEY_Comment

Fixes #3082
2023-10-03 09:10:21 +01:00
Nelson Benítez León
3c22e2745c test: improvements for GAppInfo test
· Add a usage output that is printed when called with no argument
   or with '--help' argument. This is helpful as it avoids having
   to read the source code to know how to run the different options.

 · Adds new '--should-show-only' option to 'search' command, to
   better mimick the gnome-shell app search, by not returning
   apps with NoDisplay=true.

  Example for running a desktop app search with the new option from
  inside the GLib build dir:
    $ gio/tests/apps search --should-show-only settings
2023-10-03 09:10:21 +01:00
Emmanuele Bassi
1cd0dfa55b Merge branch '3107-use-portal' into 'main'
gio: Rename GTK_USE_PORTAL to GIO_USE_PORTALS

Closes #3107

See merge request GNOME/glib!3602
2023-10-02 17:27:36 +00:00
Chun-wei Fan
b60d97f428 gconstructor.h: Ensure [c|d]tor prototypes are present for MSVC
This way, the generated GResource code won't choke if no prototypes are found
when being built by clang-cl, which also goes the _MSC_VER >= 1500 route.

Fixes clang-cl build of generated GResources code when building the appstream
git checkout, which supported Windows recently, as the build there demands
'-Werror,-Wmissing-prototypes'.

Part-of: <https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3589>
2023-10-02 18:26:19 +01:00
Philip Withnall
86fdb4c7bf Merge branch 'ebassi/issue-3130' into 'main'
Check for empty property name in GPropertyAction

Closes #3130

See merge request GNOME/glib!3599
2023-10-02 17:09:55 +00:00
Arjan Molenaar
e9f0259e5d tests: Add a test for initialising GPropertyAction with no name
Helps: #3130
2023-10-02 17:17:24 +01:00
Emmanuele Bassi
3a2af81ced Check for empty property name in GPropertyAction
Make sure to fail consistently in case people created a GPropertyAction
with g_object_new() without passing a property name.

Bindings that construct objects with g_object_new() have no idea if a
property is mandatory.

See: #3130
2023-10-02 17:17:24 +01:00
Philip Withnall
525508be0d gpropertyaction: Split dispose/finalize
This avoids a critical warning from trying to disconnect a signal
handler from a `NULL` object if `paction->object` is `NULL` for whatever
reason (see: the following commit).

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

Helps: #3130
2023-10-02 17:17:24 +01:00
Philip Withnall
bda8726437 Merge branch 'wip/abono/ifdef-ptrace-o-exitkill' into 'main'
tests/gsubprocess: Don't rely on PTRACE_O_EXITKILL presence

Closes #3128

See merge request GNOME/glib!3588
2023-10-02 14:38:25 +00:00
Philip Withnall
5bc6c2035a gio: Rename GTK_USE_PORTAL to GIO_USE_PORTALS
The `GTK_USE_PORTAL` environment variable has started to be misused by
users, which is causing deployment issues (such as portal services
themselves ending up being forced to use portals, which is never going
to work).

Try and sidestep users’ broken configurations by renaming the
environment variable, and also separating it from the old GTK
environment variable, since the GLib one affects a lot more processes.
This environment variable is meant to be used for
debugging and development, and never in production.

GTK already renamed their environment variable in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4829, so keeping the
`GTK_USE_PORTAL` name in GLib doesn’t make sense anyway.

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

Fixes: #3107
2023-10-02 15:00:23 +01:00
Xavier Claessens
4700e89f53 Merge branch 'pcre2' into 'main'
meson: Fix Windows build with PCRE2 as sibling subproject

See merge request GNOME/glib!3601
2023-10-02 10:52:38 +00:00
Benjamin Gilbert
34e457e9f1 meson: Fix Windows build with PCRE2 as sibling subproject
If glib and PCRE2 are both built for Windows as subprojects of a parent
project, cc.links() will fail because PCRE2 hasn't been built yet when
glib is being configured:

    subprojects/glib-2.78.0/meson.build:2109:20: ERROR: Dependencies must be external dependencies

609d58beea changed the detection logic to avoid cc.links() in this
case, but dd5683ce64 broke it again.  PCRE2 detection could use a
broader cleanup, but for now, make the minimum change to fix this case.

use_pcre2_static_flag ends up set to false, matching the behavior of
609d58beea.

Fixes: dd5683ce64 ("meson: Allow fallback & static build of pcre subproject")
2023-10-01 23:06:49 -05:00
Emmanuele Bassi
722dba7ccf Merge branch 'ebassi/fundamental-max-value' into 'main'
Add value annotation to G_TYPE_FUNDAMENTAL_MAX

See merge request GNOME/glib!3596
2023-10-02 01:12:11 +00:00
Emmanuele Bassi
70585f9a48 Add value annotation to G_TYPE_FUNDAMENTAL_MAX
The introspection parser isn't good enough to expand the shift symbol,
which means G_TYPE_FUNDAMENTAL_MAX is evaluated as (255 << 0).

We can use the `(value)` annotation to force the symbol value in the
introspection data.

See: GNOME/gobject-introspection#473
2023-10-02 01:29:50 +01:00
Emmanuele Bassi
7ed14113e7 Merge branch 'fix-gutils-user-database-test-on-macos' into 'main'
Fix gutils-user-database test on macOS

See merge request GNOME/glib!3594
2023-10-02 00:23:34 +00:00
Sabri Ünal
6f9abcdeef Update Turkish translation 2023-10-01 18:29:58 +00:00
Luca Bacci
991cb9ef8c tests/gutils-user-database: Fix test on macOS
Use DYLD interposing on macOS
2023-09-27 16:19:44 +02:00
Luca Bacci
91b41f5234 tests/gutils-user-database: do not hardcode library name
Use build_tgt.full_path() and import('fs').name()
2023-09-26 12:10:47 +02:00
Hannes Müller
3cb79ee261 gtestutils.h: Fix warning with -Wsign-conversion caused by g_assert_cmpint
With gcc and clang using -Wsign-conversion a related warning is generated
if code using glib 2.78.0 contains function g_assert_cmpint().

Warning is fixed by adding related casts. Related tests have been also
updated and will be also compiled with -Wsign-conversion to detect
related problems in future.
2023-09-22 08:57:40 +02:00
Kristjan SCHMIDT
41c9c51080 Update Esperanto translation 2023-09-19 21:57:32 +00:00
Alessandro Bono
272ec5dbca tests/gsubprocess: Don't rely on PTRACE_O_EXITKILL presence
The PTRACE_O_EXITKILL symbol was introduced in glibc 2.23. CentOS7
has glibc 2.17. Use the symbol only if it is defined.
2023-09-19 12:37:23 +02:00
Rūdolfs Mazurs
5a67a8f6c5 Update Latvian translation 2023-09-18 14:10:08 +00:00
Rafael Fontenelle
af912ba017 Update Brazilian Portuguese translation
(cherry picked from commit 13bc82d016)
2023-09-18 01:28:01 +00:00
Daniel Rusek
9e36642bbb Update Czech translation 2023-09-17 12:58:56 +00:00
Artur S0
508dba1ed8 Update Russian translation 2023-09-16 09:29:27 +00:00
Boyuan Yang
fb7a5eee97 Update Chinese (China) translation 2023-09-15 08:28:12 +00:00
Pavel Sobolev
cabc494073
Make sure the GTask is freed on a graceful disconnect
This fixes the memory leak in the case the connection has been
successfully closed by the peer.
2023-09-14 15:42:24 +03:00
Philip Withnall
56daac02d1 gthread: Fix optional/nullable annotations for g_once_init_*()
The pointer argument must not be `NULL` (though it can point to a
location which is zero/null-valued), so this should be `(not optional)`
not `(not nullable)`.

Spotted in !3577.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-09-13 14:18:55 +01:00
Luca Bacci
13c5256fd7 gthread-win32: Fix size argument passed to RaiseException
https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022#set-a-thread-name-by-throwing-an-exception
2023-09-13 14:04:26 +02:00
Luca Bacci
19d06340cf gthread-win32: Check for specific exception code
https://learn.microsoft.com/en-us/cpp/code-quality/c6320?view=msvc-170
2023-09-13 14:04:26 +02:00
Luca Bacci
f4b53cacbf gthread-win32: No need to raise thread name exception if the debugger is not present
As outlined in [1], raising the exception without a debugger attached
isn't of any use, as the thread name won't be stored anywhere.
The system doesn't trap such exception, only debuggers.

This also fixes a TOCTTOU issue between the IsDebuggerPresent() check
and the RaiseException() call.

References:
 [1] - https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022#set-a-thread-name-by-throwing-an-exception
2023-09-13 14:04:26 +02:00