Commit Graph

16982 Commits

Author SHA1 Message Date
Chun-wei Fan
958902ed9a Visual Studio builds: Redo utility script generation
Use the new gen_util_scripts.py script to generate the glib-mkenums and
gdbus-codegen scripts with the proper info in them so that they can be
used properly by other build systems such as Meson, during "install".
2017-05-24 15:47:36 +08:00
Chun-wei Fan
b095df4565 Visual Studio builds: Add script to generate utility scripts
This will allow the utility scripts glib-mkenums and gdbus-codegen be
generated with the proper info in them, as build systems such as Meson
might look for shebang lines to determine the commands that need to be
called to invoke the scripts (which is necessary for calling these
scripts on standard Windows cmd.exe)
2017-05-24 13:22:58 +08:00
Ignacio Casal Quinteiro
bae70d7482 Revert "GSocket: Fix race conditions on Win32 if multiple threads are waiting on conditions for the same socket"
This reverts commit 799f8dcd46.
This patch seems to break applications that use GTask specific
operations with GSocket. We will need to investigate a bit more
on this issue but for now we revert it and leave it for the
next major release.
2017-05-11 18:01:39 +02:00
Philip Withnall
c589084003 gmain: Allow GSource methods to be called from a finalize() callback
Temporarily increase the ref count of a GSource to 1 while calling its
finalize() callback, so that the finalize() implementation can call
GSource methods (like g_source_set_ready_time()) without causing
critical warnings. It’s safe to call those methods at this point, as the
source has been destroyed, but nothing has been freed.

This is an indirect way of fixing a race between GCancellable and
GCancellableSource, whereby the GCancellable::cancelled callback for the
GCancellableSource is not disconnected until the GCancellableSource’s
finalize() function is called. Previously, this meant there was a window
in which the GCancellableSource’s ref count was 0, but the ::cancelled
callback was still connected, and could legitimately be called as a
result of another thread calling g_cancellable_cancel() on the
GCancellable. The callback calls g_source_set_ready_time() on the
GSource, and there’s no thread-safe way of checking whether the GSource
has been destroyed. Instead, we have to change GSource so its ref count
is only decremented to 0 inside the locked section in
g_source_unref_internal() *after* the finalize() function has been
called, and hence after the GCancellable::cancelled callback has been
disconnected. The use of g_cancellable_disconnect() ensures that the
callback disconnection is thread safe.

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

https://bugzilla.gnome.org/show_bug.cgi?id=781601
2017-05-11 08:56:45 +01:00
Paolo Bonzini
5d74233476 gmain: only signal GWakeup right before or during a blocking poll
Since commit e4ee307 ("Do not wake up main loop if change is from same
thread", bug 761102), GMainContext uses context->owner to decide if the
event loop is being run in the current thread.  However, what really
matters is the phase in the prepare/query/poll/check/dispatch sequence.
Wakeups are only needed between the end of prepare and the end of poll,
and then only if prepare found that no sources were ready.

There is no need to take threads into account, because prepare, check
and all callers of conditional_wakeup all look at the new need_wakeup
flag inside LOCK_CONTEXT/UNLOCK_CONTEXT.

With this change, g_main_context_is_owner and g_main_context_wait are
the only functions for which acquire/release matters, just like before
commit e4ee307.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
2017-05-11 08:55:37 +01:00
Chun-wei Fan
21be268a30 win32/replace.py: Fix replacing items in files with UTF-8 content
Some files that this script will process might have UTF-8 items in
there, which can cause problems on Python 3.x as it is more strict and
careful on unicode issues.  Fix this by:

-Doing what we did before on Python 2.x
-Open the file with encoding='utf-8' on Python 3.x
2017-05-09 18:21:45 -07:00
Ondrej Holy
b8bd46bc86 gunixmounts: Prevent unwanted automount requests
mnt_table_is_fs_mounted causes unwanted automount requests due to
canonicalization of source and target. It might be replaced by
mnt_table_find_source as per the documentation in order to prevent
the automounts, but it is redundant. All mtab entries should be already
mounted and thus mnt_table_is_fs_mounted result is always true (it
basically checks that the fs from mtab is in mtab). Let's remove
the check at all.

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-05-09 14:34:30 +02:00
Matthias Clasen
bbe2286be3 2.52.2 2.52.2 2017-05-08 11:28:22 -04:00
Matthias Clasen
3a6811a460 portal support: Raise the priority for network monitor
When we are inside a sandbox, we want to use the portal
implementation, since it is the only one that has a chance
of working.

This is safe to do, since the portal implementation will
just fail initialization when loaded outside a sandbox.
2017-05-02 07:29:25 -04:00
Daniel Macks
ab333f42b6 Implement g_content_type_is_mime_type() (clone of win32's)
Add missing function, copying from gcontenttype-win32.c per Patrick
Griffis (Comment #55 of bug report)

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:42:12 -04:00
Rafal Luzynski
bd555b9ba0 gosxappinfo: fix typo in g_osx_app_info_launch_internal
Correct error domain is G_IO_ERROR.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:42:02 -04:00
Patrick Griffis
917f3068c3 gosxappinfo: Special case x-scheme-handler
This is the only way they are exposed on Unix so we need to handle it

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:41:50 -04:00
Patrick Griffis
eb0fbe633c gosxappinfo: Fix get_default_for_type() on 10.10+
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:41:29 -04:00
Patrick Griffis
d99af84a36 build: Don't build dbus-appinfo on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=780309
2017-04-27 21:53:56 -04:00
Patrick Griffis
4246b1ef8c gosxappinfo: Fix typo in ifdef
https://bugzilla.gnome.org/show_bug.cgi?id=780300
2017-04-27 21:53:39 -04:00
John Lindgren
2eddcef1e7 Do not mix declarations with code.
https://bugzilla.gnome.org/show_bug.cgi?id=781298
2017-04-18 14:30:13 +08:00
Kukuh Syafaat
bed861bcf8 Update Indonesian translation 2017-04-16 03:36:18 +00:00
Paolo Bonzini
2b47c8360c gmain: Signal wakeups if context has never been acquired as well
Should address backwards compatibility with how qemu is using
`GMainContext`.

See https://bugzilla.gnome.org/show_bug.cgi?id=761102#c14

Input-into-keyboard-by: Colin Walters <walters@verbum.org>
2017-04-11 11:56:11 -04:00
Colin Walters
1d38e6cf6f main: Create a helper function for "owner wakeup" optimization
The original patch really should have introduced a helper - among
other things it deserves a code comment.  We're likely to make
further changes too, so it's obviously better to only do it in one
place.

See: https://bugzilla.gnome.org/show_bug.cgi?id=761102
2017-04-11 11:56:07 -04:00
Matthias Clasen
8ef5eae694 2.52.1 2.52.1 2017-04-08 01:55:00 -04:00
Philip Withnall
35060eb9ae gfileutils: Add precondition checks to g_file_test()
Otherwise g_file_test(NULL, …) causes a call to access(NULL, …) on
Linux, which is disallowed and valgrind complains about it.

https://bugzilla.gnome.org/show_bug.cgi?id=755046
2017-04-08 01:47:34 -04:00
Ole André Vadla Ravnås
632a224cab gdbus: fix false positive g_warning() in remove_filter()
The GDBus thread might be holding a ref while requesting to remove the
filter.

https://bugzilla.gnome.org/show_bug.cgi?id=779409
2017-04-08 01:47:23 -04:00
Adrian Perez de Castro
4d1d5b4544 Better documentation for g_app_info_equal()
Explicitly state that the function may not compare the contents of the
passed GAppInfo instances.

This fixes bug #777961.
2017-04-08 01:47:11 -04:00
Alexandros Frantzis
13b67ea290 gdbus: Fix memory leak in gdbusmethodinvocation.c
https://bugzilla.gnome.org/show_bug.cgi?id=780924
2017-04-08 01:46:55 -04:00
Philip Withnall
6d56878b75 gvariant: Minor documentation tweak for g_variant_get_fixed_array()
Add a missing clausal comma, and add some backtick formatting.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-08 01:46:44 -04:00
Debarshi Ray
c3f555b69e docs: Clarify the use of the GError in g_tls_database_verify_chain*
Being able to determine that a certificate chain is invalid is not
considered an error, but success. This might not be obvious at first
due to the way the method is named and described currently. Since we
cannot change the name, let's improve the description and clarify this
aspect of its behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=780310
2017-04-08 01:46:34 -04:00
Philip Withnall
f7ca0a197e gio: Handle NULL cached properties in NetworkManager monitor
g_dbus_proxy_get_cached_property() and
g_dbus_proxy_get_cached_property_names() can both return NULL if the
property cache is empty. Avoid a crash if this situation arises (which
it looks like it could, from reading the code) by gracefully bailing out
on NULL return values.

Coverity issues: #1257044, #1257045

https://bugzilla.gnome.org/show_bug.cgi?id=741229
2017-04-08 01:46:12 -04:00
Philip Withnall
20fcc2d1cb gsocket: Fix potential multiplication overflow calculating timeout
socket->priv->timeout is only a guint, and the multiplication is
performed before it’s widened to gint64 to be stored in start_time
(thanks, C). This means any timeout of 50 days or more would overflow.
Fixing this bug makes me feel a real sense of self-worth.

Coverity ID: 1159478

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-08 01:46:05 -04:00
Philip Withnall
b010caeca8 build: Include gettext libraries for static compilation on Mac OS X
When compiling statically against the system-provided gettext on Mac OS
X, GLib needs to be linked against CoreFramework, which provides some
functions used by gettext.

Fix this by including the necessary macro magic from upstream gettext.

https://bugzilla.gnome.org/show_bug.cgi?id=725894
2017-04-08 01:45:37 -04:00
Colin Walters
2a38996618 gdbusprivate: Include a few headers to fix win32 build
Followup to previous commit.

See: https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-04-08 01:44:27 -04:00
Colin Walters
4367515d06 gdbus: Initialize types earlier to break proxy <-> connection deadlock
This will help us break generic GType deadlocks between people using
GDBus in different threads (which is supported), not just by GType
usage in the GDBus thread.

This should fix the common cases we're seeing in the wild, although I
have some lingering concerns that if someone e.g. referenced
e.g. `G_TYPE_DBUS_AUTH_MECHANISM_SHA1` etc. we'd need to add those
too.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-04-08 01:44:19 -04:00
INSUN PYO
7725280cbf gdbus: Initialize types at async entrypoints
This isn't a comprehensive fix, but should cover a lot of cases
for GDBus.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-04-08 01:44:12 -04:00
Patrick Griffis
2f2100433f gosxcontenttype: Fix various tests
https://bugzilla.gnome.org/show_bug.cgi?id=780384
2017-04-08 01:44:06 -04:00
Patrick Griffis
36f32134be build: Skip gdesktopappinfo tests on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=780384
2017-04-08 01:43:59 -04:00
Philip Withnall
2d0b6c2b86 gmessages: Don’t check G_MESSAGES_DEBUG in old logging API
Now that the old logging API forwards through to the new structured
logging API, we don’t need to check the level or domain of a message
against INFO_LEVELS or G_MESSAGES_DEBUG — just pass it straight through
to the new structured logging API writer function.

https://bugzilla.gnome.org/show_bug.cgi?id=775879
2017-04-08 01:43:36 -04:00
Marc-André Lureau
082343f802 gio-querymodules: fix memory leak
Spotted thanks to ASAN.

https://bugzilla.gnome.org/show_bug.cgi?id=778207

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-04-08 01:43:23 -04:00
Philip Withnall
ad1040ed0c ghash: Document order of parameters in GEqualFunc usage
See https://bugzilla.gnome.org/show_bug.cgi?id=698064#c15.
2017-04-08 01:43:15 -04:00
Philip Withnall
2ea36106b7 ghash: Fix gtk-doc syntax in a documentation comment 2017-04-08 01:43:07 -04:00
Philip Withnall
5596bfb71e gbase64: Fix base-64 stepped encoding with small chunks
If encoding with small chunks such that the call to
g_base64_encode_close() has to deal with 0 < x < 24 bits of remaining
state, the encoding code would not correctly use zeroes to pad out the
state — it would use left-over state from an earlier iteration in the
encoding process.

This resulted in invalid base-64 encodings.

Add a unit test for incremental encoding using different sized chunks
too.

Thanks to Rainier Perske for reporting and analysing the bug.

https://bugzilla.gnome.org/show_bug.cgi?id=780066

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-08 01:42:58 -04:00
Philip Withnall
e7fc0bf389 gmain: Document that set_ready_time() is safe on destroyed GSources
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-04-08 01:42:49 -04:00
Philip Withnall
e6dddc3636 gmain: Document threading properties of g_source_is_destroyed()
https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-04-08 01:42:40 -04:00
Philip Withnall
e4ce400e8f gio: Drop redundant g_source_is_destroyed() calls
These calls cause race warnings from tsan, but are not a thread safety
problem, because we can only ever observe single bit changes: all
modifications to the GSource.flags field are done with a lock held; all
reads are of independent fields, so no intermediate state can ever be
observed. This assumes that a non-atomic read will consistently give us
an old value or a new value.

In any case, these g_source_is_destroyed() calls can happen from any
thread, and the state could be changed from another thread immediately
after the call returns; so the checks are pointless. In addition,
calling g_source_set_ready_time() or g_source_destroy() on a destroyed
source is not a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-04-08 01:41:05 -04:00
Philip Withnall
f46cbf6b08 gmodule: Add the visibility attribute to G_MODULE_EXPORT on gcc
For versions of GCC which support it (≥ 4), define G_MODULE_EXPORT as
__attribute__((visibility("default"))). This is normally a no-op, unless
compiling with -fvisibility=hidden, in which case it marks a symbol to
be publicly exported from the library, which is what G_MODULE_EXPORT is
for. Previously G_MODULE_EXPORT has only worked on Windows.

The compatibility check for whether the compiler supports
__attribute__((visibility)) is based on the __GNUC__ define, and is
similar to the check done in configure.ac for defining G_GNUC_INTERNAL.

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

https://bugzilla.gnome.org/show_bug.cgi?id=778287
2017-04-08 01:40:49 -04:00
Mario Sanchez Prada
261de46cca appinfo: Don't hardcode strings for the OpenURI portal's D-Bus method
We added several #define in the previous commit, so use those instead.
2017-04-08 01:40:34 -04:00
Mario Sanchez Prada
49cdd2a3aa appinfo: Launch the OpenURI portal using a synchronous D-Bus call
Calling the D-Bus method for the OpenURI portal "protects" the logic from
not ever having the remote method running in case the xdg-desktop-portal
process is not yet running and the caller quits quickly after the call.

This should not be a problem as the method returns immediately (regardless
of the user making a selection), but making it synchronous would prevent
situations where the OpenURI method would never be called because of D-Bus
dropping the message after the caller dies, without explicitly waiting for
a reply.

https://bugzilla.gnome.org/show_bug.cgi?id=780441
2017-04-08 01:40:24 -04:00
Mario Sanchez Prada
50960f80ce appinfo: Don't leak the session bus in launch_default_with_portal_async
The session bus object needs to be unreferenced before early returning.
2017-04-08 01:39:56 -04:00
Daniel Macks
34c7541edc Do not build utf8_encode on CARBON platform
utf8_encode is not used by g_utf8_collate_key on this platform.

https://bugzilla.gnome.org/show_bug.cgi?id=780306
2017-04-08 01:39:47 -04:00
Philip Withnall
25f12a54d2 gutf8: Clarify documentation for g_utf8_get_char_validated()
There is no such thing as ‘no maximum’ when reading a string. It’s got
to end somewhere.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780095
2017-04-08 01:39:33 -04:00
Philip Withnall
d5cd8322cc gutf8: Clarify return values from g_utf8_get_char_extended()
It’s hard to remember what the difference is between -1 and -2, so give
them names.

This introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780095
2017-04-08 01:39:24 -04:00
Chun-wei Fan
865ef86d8f Visual Studio 201x builds: Fix GIO x64 Debug builds
The custom build rules did not have rules for x64 Debug builds during
the refactoring.  Fix this by removing all Platform and Configuration
conditions for it, since this is done on are configs in the same manner.

Noted by Ignacio Casal Quinteiro.
2017-04-05 00:19:57 +08:00