Commit Graph

4986 Commits

Author SHA1 Message Date
Philip Withnall
09796b3ccc Partially revert "gio: Add missing (array length) annotations"
This reverts commit 8028494335.

Adding (array length=…) to a gchar* parameter causes the GIR file to
contain an array of strings, rather than an array of characters. While
we fix GIR, revert those changes.

Some of the other changes in the file (which have an explicit
(element-type) already) are fine.

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

https://bugzilla.gnome.org/show_bug.cgi?id=765063
2017-09-21 12:05:06 +01:00
Alisa Maas
8028494335 gio: Add missing (array length) annotations
https://bugzilla.gnome.org/show_bug.cgi?id=765063
2017-09-21 11:08:12 +01:00
Robert Ancell
db2ae64636 Fix comment/docs grammar: incase -> in case 2017-09-15 13:50:41 +12:00
Chun-wei Fan
a7a6449f4d meson: Install items according to their relevance
The m4 and bash completion items are usable and relevant
depending on the host system's configuration.  So, we check for the
presence of the programs that these items depend on, and only install
them when those programs are found.

For the Valgrind suppression files, we don't install them on Windows as
Valgrind is currently not supported on Windows.

Als fix the path where the GDB helpers are installed, as the path is
incorrectly constructed.

This will fix the "install" stage when building on Visual Studio at
least as there are some post-install steps that are related to them,
which will make use of these programs.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-09-14 16:02:03 +08:00
Philip Withnall
5e55a4e243 gtlsbackend: Default to indicating no support for DTLS in GTlsBackend
I’m unsure what the original reasoning for returning TRUE by default
from supports_dtls was, but it is not backwards-compatible. If a
pre-existing GTlsBackend implementation never implements the
supports_dtls vfunc, the supports_dtls() method will magically return
TRUE rather than FALSE.

Since any backend which does implement DTLS should be implementing the
supports_dtls vfunc (and no DTLS-supporting backends have actually been
merged yet; see bug #697908), it seems safer to make this slight API
break in the name of backwards compatibility than to leave it as
returning TRUE incorrectly.

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

https://bugzilla.gnome.org/show_bug.cgi?id=787485
2017-09-13 17:38:42 +01:00
Sam Thursfield
bb26bc29e3 Make GListModelInterface::get_item usable from GObject Introspection bindings
Language bindings have so far been unable to implement the GListModel
interface because the ::get_item virtual function returns a
non-bindable type (gpointer). The `gpointer` type gets translated into
`void` by G-I meaning that get_item() implementations can't return any
items.

We can set the return type of the get_item() vfunc explicitly to
GObject, which fixes the issue.

This patch also removes the existing (type GObject) annotation on
g_list_model_get_item(), which is necessary because if its return type
matches that of the get_item() vfunc, G-I connects the two and
propagates the 'skip' annotation from one to the other resulting in the
get_item() vfunc being hidden. There's no API break here because the
'skip' annotation makes g_list_model_get_item() invisible to G-I users
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=787271
2017-09-12 12:32:20 +01:00
Philip Chimento
7b9503a4f8 docs: Clarify relationship of quit() to hold count
Calling g_application_quit() ignores the hold count; this patch adds a
warning to the documentation about other code having a hold on the
application and expecting it to exist.

https://bugzilla.gnome.org/show_bug.cgi?id=737278
2017-09-11 22:26:04 +01:00
Daniel Macks
b8f9c08a09 Avoid setting unused variables (-Wself-assign)
Setting a variable and then assigning it to itself avoids
-Wunused-but-set-variable but this specific trick is now caught by
-Wself-assign. Instead, actually use the value or don't bother
assigning it at all:

gdbusauthmechanismsha1.c: #ifdef a var decl to match its actual use use
gdbusauthmechanismsha1.c: call g_ascii_strtoll() in void context

https://bugzilla.gnome.org/show_bug.cgi?id=745723
2017-09-11 22:18:42 +01:00
Daniel Macks
190f64a0fb Avoid setting unused variables (-Wself-assign)
Setting a variable and then assigning it to itself avoids
-Wunused-but-set-variable but this specific trick is now caught by
-Wself-assign. Instead, actually use the value or don't bother
assigning it at all:

gdbusauth.c: call g_data_input_stream_read_byte() in void context
gdbusauthmechanismsha1.c: value is actually used
gdbusmessage.c: use consistent preprocessor-token protection
gthreadedresolver.c: skip over bytes in data blob
httpd.c: do something useful with the value

https://bugzilla.gnome.org/show_bug.cgi?id=745723
2017-09-11 22:14:18 +01:00
Emmanuele Bassi
5d9ccf162e gio: Annotate GDBusObjectManagerClient signal appropriately
https://bugzilla.gnome.org/show_bug.cgi?id=756009
2017-09-11 21:31:13 +01:00
Philip Withnall
1275b94fe7 gsettings: Fix copy-paste error in property documentation
This should fix the introspection binding for that property too.

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

https://bugzilla.gnome.org/show_bug.cgi?id=656502
2017-09-11 21:28:40 +01:00
Mikhail Zabaluev
e5db8ec787 Skip g_subprocess_launcher_set_child_setup() in introspection
It's not likely that the runtime of a bound language using the
introspection supports running in a process forked by a foreign
library, so that a closure programmed in that language would work
safely.

Any programming environment supporting that would probably have
its own advanced facilities for process spawning, or be able
to access the GLib spawning APIs via raw C bindings (still
represented in the introspection, (skip) only adds a flag)
and do any low-level preparatory dances as necessary for the
forked runtime.

Note that there are other APIs making use of GSpawnChildSetupFunc,
but they are usable with the closure nullified, and we cannot annotate
the closure parameters away because that would break the annotated API
for bindings; accordingly to bug #738176 comment #3, the current bindings'
users are expected to pass null.
2017-09-11 21:07:09 +01:00
Mikhail Zabaluev
48cf1d32c6 Fix up closure annotations for GSpawnChildSetupFunc
https://bugzilla.gnome.org/show_bug.cgi?id=738176
2017-09-11 21:07:08 +01:00
Alberto Ruiz
df8350b316 GSubprocessLauncher: add (transfer none) annotation
https://bugzilla.gnome.org/show_bug.cgi?id=753521
2017-09-11 20:23:13 +01:00
Philip Withnall
52dd98475c gtlsbackend: Add missing preconditions for DTLS virtual methods
Make it a bit more obvious when the DTLS methods aren’t implemented by a
particular TLS backend; return an invalid type rather than crashing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=752240
2017-09-11 19:15:15 +01:00
Cosimo Cecchi
88a39670e7 GSettingsBackend: use a GWeakRef during dispatch
Instead of a full reference, which causes problems for clients that
expect a GSettings instance to stop firing signals once they drop the
last reference.

https://bugzilla.gnome.org/show_bug.cgi?id=780861
2017-09-08 09:29:18 -07:00
Chris Lamb
e5eaca5492 gio-querymodules: Make the output reproducible
Whilst working on the Reproducible Builds effort [0], we noticed that
queryimmodules generates non-reproducible output as it iterates over the
filesystem without sorting.

Patch attached.

 [0] https://reproducible-builds.org/

Signed-off-by: Chris Lamb <lamby@debian.org>

https://bugzilla.gnome.org/show_bug.cgi?id=786983
2017-09-08 15:20:27 +01:00
Daniel Boles
b1b00517cf GApplication: Fix required # of elements in docs
The reality, as shown by our tests, is that only 2 elements are needed.
2017-09-06 21:44:25 +01:00
Cj Malone
926db3174a gdesktopappinfo.c: Drop disregarded xterm check
https://bugzilla.gnome.org/show_bug.cgi?id=786580
2017-08-23 23:55:43 +01:00
Philip Withnall
73eee8d64e tests: Fix some leaks and double-frees in the GSubprocess tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Will Thompson
65a95a5a2d gio: failing cases for subprocess cancellable bug
https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Philip Withnall
8f86d312d8 gio: Fix double-callback on cancellation with GSubprocess
See bug #786456 for a detailed analysis of the situation which can cause
this (in summary, if a g_subprocess_wait_async() call is cancelled on a
GSubprocess which is already known to be dead).

The problem was that the GCancellable callback handler was
unconditionally returning a result for the GTask for
g_subprocess_wait_async(), even if that GTask had already returned a
result and the callback was being invoked after the GTask had been
removed from the pending_waits list.

Fix that by checking whether the GTask is still in the pending_waits
list before returning a result for it.

Thanks to Will Thompson for some very useful unit tests which reproduce
this (which will be pushed in the following commit).

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

https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Philip Withnall
a60359aee2 tests: Add temporary working directory for monitor test
Similarly to the previous commit, move the temporary directory for the
monitor test from $(cwd) to the system temporary directory.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Philip Withnall
0f5b523fac tests: Add temporary working directory for appmonitor test
Rather than creating a temporary directory in the current directory
(typically the builddir), then never deleting it; create one in the
system /tmp directory, and clean it up properly afterwards.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Philip Withnall
3ce00b29ec tests: Fix leak in appmonitor test
Spotted by Daniel Macks.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Ondrej Holy
087525b62b gio-tool: Use print_file_error correctly
Use print_file_error where an error relates to that file and vice versa.

https://bugzilla.gnome.org/show_bug.cgi?id=786463
2017-08-18 14:46:23 +02:00
Ondrej Holy
78fa67e70c gio-tool-save: Use g_output_stream_write_all instead of while
Simplify the read-write copy code and use g_output_stream_write_all
instead of while and g_output_stream_write.

https://bugzilla.gnome.org/show_bug.cgi?id=786462
2017-08-18 14:46:23 +02:00
Ondrej Holy
1cce5dda18 gfile: Use g_output_stream_write_all instead of while
Simplify the read-write copy code and use g_output_stream_write_all
instead of while and g_output_stream_write.

https://bugzilla.gnome.org/show_bug.cgi?id=786462
2017-08-18 14:46:23 +02:00
Ondrej Holy
c7f2a7e431 gio-tool-save: Prevent overwriting error
The following warning is shown, when both g_output_stream_write and
g_output_stream_close fail:
"GError set over the top of a previous GError or uninitialized memory."

Let's clear the error after use.

https://bugzilla.gnome.org/show_bug.cgi?id=786463
2017-08-18 14:46:23 +02:00
Ondrej Holy
37cddec0ee gio-tool: Unify buffer sizes
Recently, buffer size for copying has been increased in order to improve
performance:
https://bugzilla.gnome.org/show_bug.cgi?id=773823

Let's do the same for gio-tool-save and gio-tool-cat.

https://bugzilla.gnome.org/show_bug.cgi?id=786460
2017-08-18 14:46:23 +02:00
Chun-wei Fan
54aee1f627 Meson: Set _WIN32_WINNT to 0x0601 (Windows 7)
We want to set _WIN32_WINNT so that functions will be properly found in
the headers, to target the NT6.1+ (Windows 7+) APIs.

Also improve the checks for if_nametoindex() and if_indextoname() on
Windows as they are supported in Windows Vista+, but they have
to be checked by linking against iphlpapi.lib (or -liphlpapi).  On other
platforms, they are still checked as they were before.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-08-17 23:40:35 +08:00
Chun-wei Fan
32d6a76b98 build: Use Meson's find_library() for MSVC builds as needed
Some of the dependencies' build systems for Visual Studio do not provide a
pkg-config file upon build, so we use find_library() for them when the
corresponding pkg-config files are not found during Visual Studio builds,
so that one will not need to make up pkg-config files for them, which
could be error-prone.  These .lib names match the names that are built
with the officially supported build system that is used by their
respective Visual Studio support.

For ZLib, this will make gio-2.0.pc reflect on the zlib .lib based on
what is found, or whether we use the fallback/bundled ZLib, when we
don't have a pkg-config file for ZLib on MSVC.  We still need to depend
on Meson to be updated to put the correct link argument for linking ZLib
in the pkg-config case.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-08-17 17:17:59 +08:00
Simon McVittie
7c97e3d784 gdbus: Check signature of NameAcquired, NameLost
Calling g_variant_get (parameters, "(&s)") when parameters has a
signature other than (s) is considered to be a programming error.
In practice the message bus (dbus-daemon or a reimplementation) should
always send the expected type, but be defensive.

(Modified by Philip Withnall to improve type check.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:31:31 +01:00
Simon McVittie
c53b44edb2 GBusNameOwnerFlags: Add DO_NOT_QUEUE flag
PulseAudio and LibreOffice are among the services that use this flag.
Refusing to queue for a name lets you do this transaction,
but atomically, avoiding the transient state where you briefly join
the queue and then are given the name when its primary owner drops it:

    result = RequestName(name)

    if result == IN_QUEUE:
        ReleaseName(name)
        result = EXISTS

    return result

(Modified by Philip Withnall to add documentation.)

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

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:16:07 +01:00
Simon McVittie
92f1ba200d GBusNameOwnerFlags: Note equivalence with D-Bus Specification
The implementation passes flags through directly to the RequestName()
call, so if any new values break that equivalence, the implementation
will have to be changed.

Signed-off-by: Simon McVittie <smcv@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:10:07 +01:00
Philip Withnall
05abc6cfce gio: Fix crash in open URI portal when no callback is provided
If no callback is provided, token is never set, but it’s then passed to
g_variant_new_string(), which requires a non-NULL input.

Fix that by moving all the option handling inside the (callback != NULL)
case.

Spotted by Coverity (CID #1378714).

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

https://bugzilla.gnome.org/show_bug.cgi?id=785817
2017-08-07 17:08:07 +01:00
Philip Withnall
1782219fb8 docs: Fix typo in GDBusInterfaceSkeleton documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-04 13:30:10 +01:00
Philip Withnall
ad9d5a11f2 tests: Fix gschema-compile test for translatable string changes
Little did I know when making commit
c257757cf6 that a lot of the output of
glib-compile-schemas is string matched in some of the unit tests. Fix
them to match the updated strings.

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 16:32:42 +01:00
Philip Withnall
25c01e1c55 glib-compile-schemas: Use double quotes rather than single quotes
It’s what GLib is standardising on. See bug #772221.

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 16:31:37 +01:00
Daniel Macks
f7a14fece4 Use "-module" when compiling loadable modules
Some platforms use different extensions for compile-time linkable
libraries vs runtime-loadable modules. Need to use special libtool
flag in the latter case for consistency with what gmodule expects.

https://bugzilla.gnome.org/show_bug.cgi?id=731703
2017-08-03 12:28:10 +01:00
Philip Withnall
c257757cf6 glib-compile-schemas: Improve some translatable strings
• Fix capitalisation to be consistent
 • Use Unicode quotation marks where appropriate
 • Move trailing \n characters out of the translable strings and append
   them unconditionally

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:41:13 +01:00
Daniel Boles
94816e10d2 glib-compile-schemas: Fix typo in newly translatable string 2017-08-03 11:30:20 +01:00
Jiro Matsuzawa
a7aa8acc48 glib-compile-schemas: Mark missing strings for translation
https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:19:08 +01:00
Philip Withnall
f2b6c11629 gstrfuncs: Expand documentation for errno functions
Mention that it really is a good idea to save errno before doing
literally anything else after calling a function which could set it.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Philip Withnall
5cddde1fb2 Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.

errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
  int errsv, ret;
  ret = some_call_which_might_set_errno ();
  errsv = errno;

  if (ret < 0)
    puts (strerror (errsv));

This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
  if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Ondrej Holy
41a4a70b43 gunixmounts: Add missing const qualifier for mtab path
get_mtab_read_file and get_mtab_monitor_file returns const path,
but const qualifier is missing. Let's add it.

https://bugzilla.gnome.org/show_bug.cgi?id=779607
2017-08-03 10:22:43 +02:00
Ondrej Holy
2db36d0d5c gunixmounts: Prevent "mounts-changed" race if /etc/mtab is used
The /etc/mtab file is still used by some distributions (e.g. Slackware),
so it has to be monitored instead of /proc/self/mountinfo in order to
avoid races between g_unix_mounts_get and "mounts-changed" signal. The
util-linux is built with --enable-libmount-support-mtab in that case and
mnt_has_regular_mtab is used for checks. Let's use mnt_has_regular_mtab
also to determine which file to monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=779607
2017-08-03 10:22:43 +02:00
Debarshi Ray
b51a0e7c63 GApplication: Use a WARNING if dbus_unregister is called by destructor
Unlike g_application_register, there is no public API to unregister the
GApplication from D-Bus. Therefore, if the GApplication is set up
manually without using g_application_run, then neither can the
GApplicationImpl be destroyed nor can dbus_unregister be called before
destruction.

This is fine as long as no sub-class has implemented dbus_unregister.
If they have, their method method will be called after destruction, and
they should be prepared to deal with the consequences.

As long as there is no public API for unregistering, let's demote the
assertion to a WARNING. Bravehearts who don't use g_application_run
can continue to implement dbus_unregister, but they would have been
adequately notified.

This reverts commit c1ae1170fa.

https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-24 19:52:48 +02:00
Debarshi Ray
df06dc6550 GApplication: Don't call dbus_unregister multiple times
https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-24 19:52:48 +02:00
Debarshi Ray
c1ae1170fa GApplication: Assert that dbus_unregister was called before destruction
Invoking the dbus_unregister virtual method during destruction is
problematic. It would happen after a sub-class has dropped its
references to its instance objects, and it is surprising to be asked to
unexport exported D-Bus objects after that.

This problem was masked as a side-effect of commit 21b1c390a3.
Let's ensure that it doesn't regress by asserting that dbus_unregister
has happened before destruction.

Based on a patch by Giovanni Campagna.

https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-20 15:31:41 +02:00