Commit Graph

20556 Commits

Author SHA1 Message Date
Chun-wei Fan
2e5d3aa911 glib/gtimezone.c: Use RegLoadMUIStringW() to query Std/Dlt strings
The existing method of using RegQueryValueExW() to query the Std/Dlt
strings can only retrive the localized versions of those strings, so
that means they will vary by the language version of Windows.  Instead,
use RegQueryValueExW() only as a fallback when RegLoadMUIStringW() fails,
as RegLoadMUIStringW() can query for the Std and Dlt strings in
whatever language we need by setting the locale stuff programatically on
the fly.
2019-07-05 18:52:02 +08:00
Chun-wei Fan
c868123c0a glib/gtimezone.c: Use Unicode versions of Windows Registry API
We are going to use RegLoadMUIStringW() in the next commit, since there
is no real RegLoadMUIStringA() function (it exists as a stub only).
This is done so that we are consistent along the way

Also fix rule_from_windows_time_zone_info() as we can't just do a strncpy()
of tzi->StandardName and tzi->DaylightName directly, as they are wchar_t/
gunichar2 strings, where we must convert to UTF-8 first.

https://bugzilla.gnome.org/show_bug.cgi?id=719344
2019-07-05 18:51:49 +08:00
Philip Withnall
dc774db608 Merge branch 'dboles/gmacros-docs' into 'master'
docs.c: Forward link from g_auto* → G_DEFINE_AUTO*

See merge request GNOME/glib!971
2019-07-05 09:56:42 +00:00
Daniel Boles
71ccfadbe1 docs.c: Forward link from g_auto* → G_DEFINE_AUTO*
We said the type must support being cleaned up and will be cleaned up in
an appropriate way, but in order to figure out how to do that, you had
to jump forward in the documentation to the other macros. Just say them.
2019-07-05 10:34:27 +01:00
Philip Withnall
1230be3d11 Merge branch 'wip/lantw/gdatetime-unset-lc-all-for-the-test-as-well' into 'master'
gdatetime: Unset LC_ALL for the test as well

See merge request GNOME/glib!970
2019-07-05 09:30:56 +00:00
Ting-Wei Lan
7089f67f14 gdatetime: Unset LC_ALL for the test as well
This is a follow-up to a0c7f85437.

In addition LC_MESSAGES, we should remove LC_ALL from the environment
as well. Otherwise, LC_ALL overrides LC_MESSAGES, causing the test to
fail on FreeBSD when LC_ALL is set to a non-English locale.
2019-07-05 15:13:11 +08:00
Philip Withnall
8efe050a39 Merge branch 'master' into 'master'
Fix typo in request handle

See merge request GNOME/glib!968
2019-07-04 16:23:45 +00:00
David Strauss
979c92df17 Fix typo in request handle 2019-07-04 16:23:44 +00:00
Matthew Leeds
d4db5a8288 gtestdbus: Clarify comment on dropping connection ref
In _g_object_unref_and_wait_weak_notify() we take a weak reference and
then call g_object_unref() in an idle callback, which may look like
we're dropping a strong reference without having one. So change the
comment to make it more clear that the reference being dropped is held
by the caller.
2019-07-03 20:28:36 -07:00
Matthew Leeds
59ce6b10dc gdbus-connection-loss: Fix test failure
Now that we're not calling g_object_run_dispose() indirectly in
g_test_dbus_down() (see commit "Revert "gtestdbus: Properly close server
connections""), the test gdbus-connection-loss is failing with the
message "Bail out! GLib-GIO-FATAL-WARNING: Weak notify timeout, object
ref_count=1". This is because we're holding a reference to the singleton
connection object while calling session_bus_down() in the test's main().
So then we end up waiting for 30 seconds in
_g_object_unref_and_wait_weak_notify() for the GWeakNotify to be
triggered, which never happens.

The fix is to unref the connection before calling session_bus_down().
This is consistent with how other tests work, and is safe because the
only method called on the connection has already errored out, as
asserted by the test.
2019-07-03 20:28:36 -07:00
Matthew Leeds
1c63d5d539 Revert "Work around test failure in gdbus-names"
This reverts commit c37cd19fee.

Now that we've reverted the commit "gtestdbus: Properly close server
connections", g_test_dbus_down() no longer returns early and we no
longer need this workaround. Since the gdbus-names test seems to
properly unref its GDBusConnection objects it's not clear to me why it
needed the sleep to succeed. However even at the time the failure wasn't
reproducible according to this comment[1] so it's probably not worth
spending more effort trying to reproduce it now.

[1] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214235
2019-07-03 20:21:34 -07:00
Matthew Leeds
d03025ba10 Revert "gtestdbus: Properly close server connections"
This reverts commit baf92d09d6.

Closes #787

According to the original commit, this change was made because otherwise
g_test_dbus_down() following a g_test_dbus_stop() hangs until it times
out. The timeout being referred to is the 30 seconds which are waited by
_g_object_unref_and_wait_weak_notify() for the GWeakNotify to be
triggered when the last strong reference to the singleton
GDBusConnection object is dropped. But the patch was not correct and the
leak should have instead been fixed by having the last strong reference
holder drop their reference on the GDBusConnection before calling
g_test_dbus_down(). Timing out after 30 seconds is the desired behavior
in the case where someone holds a reference to the singleton for that
entire period.

There are a few problems with this patch. First, as pointed out here[1],
calling g_object_run_dispose() in the idle callback means we are causing
the GWeakNotify to trigger ~immediately rather than waiting 30 seconds
to give another owner a chance to unref. Second, since someone else may
still hold a reference on the object being disposed, they may call
methods on it after it's been disposed which can seg fault as documented
here[2] and as I also saw recently in another project.

It's unclear what the original leak being fixed was, but many have been
fixed between 2013 and now. I ran all the unit tests under valgrind, and
some do fail (some consistently and some intermittently) but none of the
failures seem to only happen after this reversion commit. I also
couldn't find anywhere in the valgrind output where any GDBusConnection
objects are definitely being lost.

[1] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214226
[2] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214237
2019-07-03 20:01:22 -07:00
Philip Withnall
91c1f33bb4 Merge branch 'win32-gstdio-minor' into 'master'
gstdio: minor cleanups

See merge request GNOME/glib!939
2019-07-03 11:06:01 +00:00
Philip Withnall
25c9b9bace Merge branch 'wip/desrt/gcond-errno-fixup' into 'master'
gthread: fix minor errno problem in GCond

See merge request GNOME/glib!958
2019-07-02 10:46:11 +00:00
Allison Karlitskaya
de009c1e91 tests: test g_cond_wait_until() under stress
This (dubious) testcase fails before the previous commit due to errno
being clobbered by the interrupted wait on the contended mutex.  The
previous commit fixes that.

The testcase is dubious because, in theory (as per POSIX),
g_cond_wait_until() is permitted to return TRUE at any time for any
reason, due to so-called "spurious wakeups".  Having a testcase that
asserts that the return value should be FALSE is therefore fundamentally
broken.  We do it anyway, though.

We're only really trying to test a bug in our homemade Linux/futex
implementation here, and it takes a fair amount of effort to actually
convince the old code to fail (including some system stuff which
probably isn't available on Windows).  There's also the spurious wakeup
situation mentioned above to worry about on other systems.  For all of
those reasons, this test is only enabled on Linux.
2019-07-02 12:22:16 +02:00
Allison Karlitskaya
d92f22ab47 gthread: fix minor errno problem in GCond
The return value from `g_cond_wait_until()` is calculated, based on the
value of `errno` after reacquiring the mutex.  This is a problem because
`errno` can be overwritten in the case the mutex is contended (in which
case the slow-path code will re-enter the kernel).

Perform the calculation before reacquiring the mutex.

See merge request GNOME/glib!958
2019-07-02 12:22:07 +02:00
Philip Withnall
01bc57576b Merge branch 'msvc-static-assert' into 'master'
gmacros.h: Use static_assert on MSVC if possible

See merge request GNOME/glib!964
2019-07-02 10:13:19 +00:00
Chun-wei Fan
7b91440ca4 gmacros.h: Use static_assert on MSVC if possible
Visual Studio 2010 and later support static_assert on both C and C++,
but we can only enable it for plain-C code on Visual Studio 2013 and
later, as apparently the static_assert macro implementation will carry
out something after defining certain variables.

For C++ code, we use static_assert on Visual Studio 2010 and later.
2019-07-02 11:52:52 +08:00
Emmanuele Bassi
a656555f76 Merge branch 'nirbheek/static-assert-try-2' into 'master'
gmacros: Use _Static_assert only for non-expr static assert

See merge request GNOME/glib!962
2019-07-01 13:41:58 +00:00
Nirbheek Chauhan
b169b5a45d gmacros: Use _Static_assert only for non-expr static assert
We can't actually use it inside an expression, so keep the old macro
for that. Also add a test so that this doesn't break the next time we
change it.

See: https://gitlab.gnome.org/GNOME/glib/merge_requests/955#note_542646
2019-07-01 13:41:58 +00:00
Ondrej Holy
66d2135146 Merge branch 'fix-find_enclosing_mount-documentation' into 'master'
Fixing find_enclosing_mount() documentation

Closes #453

See merge request GNOME/glib!943
2019-07-01 13:29:02 +00:00
Emmanuel Fleury
7c0b11248f Fixing find_enclosing_mount() documentation
Fix issue #453
2019-07-01 15:00:42 +02:00
Michael Catanzaro
0c9dab3671 Revert "gmacros: Use _Static_assert when C11 is available"
This reverts commit 5d14764a6b.

It broke G_STATIC_ASSERT_EXPR(). See discussion in !955.
2019-06-29 13:48:08 -05:00
David Emett
ca47f3dfd5 gmain: Fix g_main_context_prepare priority annotation 2019-06-29 14:13:16 +01:00
Philip Withnall
f7f267522d Merge branch 'wip/mjog/utf8-norm-missing-nullable-annotation' into 'master'
g_utf8_normalize: Doc comment return missing nullable annotation

See merge request GNOME/glib!953
2019-06-29 08:44:15 +00:00
Michael Gratton
af9696caad g_utf8_normalize: Doc comment return missing nullable annotation
The return value for g_utf8_normalize may be null, but the return type
is not annotated as such. This is important for language bindings for
langs that are about nullability, such as Vala and Haskell.
2019-06-29 15:06:20 +10:00
Philip Withnall
f05dbab003 gtestutils: Set coredump rlimit to 0 when calling g_test_trap_fork()
g_test_trap_fork() is deprecated, but it’s still tested in the GLib
tests. If we don’t set the coredump rlimit to 0 to prevent coredumps,
the test for it creates a coredump (which is expected). On systems with
systemd-coredump, that causes systemd-coredump to spawn and process the
coredump for a while. That slows down the tests, and results in spurious
coredump lists in the system logs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #436
2019-06-28 13:05:07 +01:00
Philip Withnall
d55f6fb5fe gdesktopappinfo: Update calling convention for gnome-terminal
For several years now (I haven’t looked up the exact date),
`gnome-terminal` has preferred being called as `gnome-terminal
--terminal-args -- /some/other/program --its-args` rather than as
`gnome-terminal --terminal-args -x /some/other/program --its-args`.
Since 2017 it has warned about uses of `-x` (see
ad4edbd118).

So we should change our calling convention for it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-28 13:05:07 +01:00
Philip Withnall
d50caa8fb9 tests: Don’t spawn test processes via the terminal in the appinfo test
There seems to be no reason to do so, and since the `appinfo` test was
ported to use `G_TEST_OPTION_ISOLATE_DIRS`, it has been causing
coredumps to accumulate. `gnome-terminal` was chosen as the terminal,
but it couldn’t find its GSettings schemas due to all the XDG
environment variables being cleared to `/dev/null` by
`G_TEST_OPTION_ISOLATE_DIRS`.

In order to keep using `gnome-terminal` as a subprocess in the tests,
we’d need to explicitly set up its environment so it can load the right
GSettings schemas. That’s a lot of work for not much gain.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #436
2019-06-28 13:05:07 +01:00
Philip Withnall
f2a979cbaa Merge branch 'adding_g_array_copy' into 'master'
Adding a function g_array_copy() to glib/garray.c

Closes #236

See merge request GNOME/glib!872
2019-06-28 11:05:49 +00:00
LRN
5e7c18fa48 Merge branch 'nirbheek/preliminary-uwp-support' into 'master'
Preliminary patches for Universal Windows Platform support

See merge request GNOME/glib!951
2019-06-27 16:08:59 +00:00
Emmanuel Fleury
46f70e9901 Adding a function g_array_copy() to glib/garray.c
Original code from Simon van der Linden

Close issue #236
2019-06-27 13:40:26 +02:00
Philip Withnall
75614a0972 Merge branch 'improve_g_ptr_array_api' into 'master'
Adding g_ptr_array_copy() and g_ptr_array_extend() to garray API

Closes #269

See merge request GNOME/glib!918
2019-06-27 11:11:41 +00:00
Emmanuel Fleury
0675703af0 Adding g_ptr_array_extend_and_steal() function to glib/garray.c 2019-06-27 12:28:32 +02:00
Philip Withnall
7b5d1c8b06 Merge branch 'nirbheek/static-assert-c11' into 'master'
gmacros: Use _Static_assert when C11 is available

See merge request GNOME/glib!955
2019-06-27 10:20:46 +00:00
Philip Withnall
ad4a2cc345 Merge branch 'manichaean-typo' into 'master'
Fix the ISO 15924 code for Manichaean

See merge request GNOME/glib!954
2019-06-27 10:13:31 +00:00
Nirbheek Chauhan
5d14764a6b gmacros: Use _Static_assert when C11 is available
The static assert message is much nicer to read, and is less likely to
be misinterpreted as a false positive.

glib is built with `-std=gnu89`, but this macro will be available to
projects that use glib with c11 or gnu11.
2019-06-27 14:18:43 +05:30
David Corbett
2fdc35aabd Fix the ISO 15924 code for Manichaean 2019-06-26 21:31:22 -04:00
Nirbheek Chauhan
be56d90fe9 gmodule: Add support for loading UWP packaged DLLs
LoadLibrary() is not available when building for the Universal Windows
Platform, which is used for shipping apps to the Windows Store on all
devices (Windows Desktop, Windows Phone, Surface, XBox, etc).

Apps are not allowed to load arbitrary DLLs from the system. The only
DLLs they can load are those that are bundled with the app as assets.
LoadPackagedLibrary() can be used to access those assets by filename.

The function is meant to be a drop-in replacement for LoadLibrary(),
and the HANDLE returned can be treated the same as before.
2019-06-26 22:59:19 +05:30
Emmanuel Fleury
43ad244df2 Adding g_ptr_array_extend() function to glib/garray.c
Related to issue #269
2019-06-26 15:35:28 +02:00
Emmanuel Fleury
86bcc5c942 Adding g_ptr_array_copy() function to glib/garray.c
Related to issue #269
2019-06-26 15:34:47 +02:00
Philip Withnall
6a291b3e84 Merge branch 'gvalue_avoid_expensive_checks' into 'master'
gvalue: Avoid expensive checks where possible

Closes #894

See merge request GNOME/glib!946
2019-06-26 11:11:22 +00:00
Philip Withnall
40f868c189 Merge branch 'wip/lantw/enable-ci-on-freebsd-12' into 'master'
ci: Enable CI on FreeBSD 12

See merge request GNOME/glib!950
2019-06-26 11:08:44 +00:00
Philip Withnall
b555a7bfdd Merge branch 'minor-docs-improvements' into 'master'
gio: Make minor docs improvements

See merge request GNOME/glib!952
2019-06-26 11:05:05 +00:00
Matthew Leeds
1f49c5aaeb gio: Make minor docs improvements
This commit changes a comment in _g_dbus_worker_do_read_cb() to be
slightly more useful. At least in my experience debugging an
intermittent unit test failure in another project, this failure
condition occurred because although g_test_dbus_down() ensures that the
session GDBusConnection has exit-on-close set to FALSE before killing
its dbus-daemon, there was still a GDBusConnection on the system bus
which hit this failed read code path, because we had
DBUS_SYSTEM_BUS_ADDRESS set to the address of the #GTestDBus daemon, to
appease libudisks.

Also, make a few other minor improvements to the docs.
2019-06-25 11:11:33 -07:00
Nirbheek Chauhan
cdc2a798cf uwp: workaround a false positive in certification of glib
It seems that the Windows App Certification Kit searches all files and
binaries for the regex '\<reg\>' (or something like it) and throws
errors if it exists. Supposedly this is for preventing apps from
running REG.EXE

https://blogs.msdn.microsoft.com/appconsult/2017/08/16/how-to-validate-if-your-application-is-compliant-with-the-windows-store-polices-windows-10-and-windows-10-s/
2019-06-25 13:09:04 +05:30
Emmanuel Fleury
cf29e37c54 Moving GCopyFunc typedef from glib/gnode.h to glib/gtypes.h 2019-06-25 09:19:49 +02:00
Emmanuel Fleury
5f3e470eb3 gvalue: Avoid expensive checks where possible
Original patch submitted by Edward Hervey

Close issue #894
2019-06-25 09:19:11 +02:00
Philip Withnall
c411d0aa6d Merge branch 'fix-mkenums-genmarshal-test-windows' into 'master'
GObject: Fix mkenums.py and genmarshal.py tests on Windows

See merge request GNOME/glib!948
2019-06-24 16:47:30 +00:00
Ting-Wei Lan
4bf3cb0e54 ci: Enable CI on FreeBSD 12 2019-06-25 00:46:52 +08:00