Commit Graph

186 Commits

Author SHA1 Message Date
Philip Withnall
b5948c1a39 gsettings: Fix some memory leaks on error paths
Coverity CID: #1393949
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2018-07-17 12:14:07 +02:00
Allison Lortie
6ca449672d gsettingsschema: Allow per-desktop overrides
Recognise a new 'd' option in schema keys which gives a dictionary of
per-desktop default values. This dictionary is searched for the items
found in XDG_CURRENT_DESKTOP, in the order. If nothing matches (or if
the option is missing) then the default value is used as before.

This feature was requested by Alberts Muktupāvels and this patch is
based on an approach devised by them.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Allison Lortie
c2e7f31697 gsettings: cleanup default value lookup
There are a couple of different ways (and soon one more) to access the
default value of a key. Clean up the various places that access this to
avoid duplication.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Philip Withnall
9b4c50f63d all: Remove trailing newlines from g_message()/g_warning()/g_error()s
All those logging functions already add a newline to any message they
print, so there’s no need to add a trailing newline in the message
passed to them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 16:46:19 +01:00
Christophe Fergeau
fbbad525a5 gsettings: Fix leaks and assertion on range binding failures
When using g_settings_bind(), if a range binding triggers a range check
failure, g_settings_binding_property_changed() will return early, but it
won't cleanup properly causing some leaks. The binding will also still
be marked as 'running', which causes an assertion failure when trying to
free it:
"g_settings_binding_free: assertion failed: (!binding->running)"

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=794805
2018-04-11 10:42:54 +01:00
Daniel Boles
0d953f8dd2 GSettings: Don't mention nonexistent signal in doc
https://bugzilla.gnome.org/show_bug.cgi?id=622126
2018-04-09 14:15:46 +01:00
Will Thompson
5b88ed8caf
gsettings: fix typo in class documentation 2018-02-12 21:28:16 +00:00
Xiang Fan
3d4fb44653 gsettings: make g_settings_bind() documentation clearer
https://bugzilla.gnome.org/show_bug.cgi?id=789245
2017-10-23 12:20:02 +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
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Philip Withnall
84134c64ed docs: Remove some extraneous words from g_settings_sync() documentation
Looks like the author started typing one thing, then changed their mind
about how to phrase the sentence, and typed something else.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2017-04-30 22:04:17 +01:00
Philip Withnall
6bfb4ce191 gsettings: Fix a leak in GSettingsAction
Every GSettingsAction was leaking its schema key (a few tens of bytes).

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Philip Withnall
08b6794ec2 gsettings: Fix memory leak on error handling path for g_settings_set()
On the warning/critical error handling paths for g_settings_set(), the
GVariant value was not ref-sunk, and the schema key was leaked. This
won’t affect code in production (unless it’s seriously buggy), but
eliminates some leaks from the error testing paths in the GSettings
tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Christian Hergert
18a33f72db introspection: use (nullable) or (optional) instead of (allow-none)
If we have an input parameter (or return value) we need to use (nullable).
However, if it is an (inout) or (out) parameter, (optional) is sufficient.

It looks like (nullable) could be used for everything according to the
Annotation documentation, but (optional) is more specific.
2016-11-22 14:14:37 -08:00
Piotr Drąg
10c490cdfe Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2016-10-12 21:30:42 +02:00
Lars Uebernickel
0e5e3d0d65 gsettings: clarify changed signal documentation
Make it clear that this signal is only guaranteed to be emitted when a
key has been read before.

https://bugzilla.gnome.org/show_bug.cgi?id=750257
2016-07-16 23:26:56 -04:00
Ryan Lortie
ca03753853 g_settings_reset(): add precondition checks
Ensure that @key is non-%NULL on g_settings_reset().

It turns out that using g_settings_reset() with %NULL key (although
invalid as per the API documentation and not possible via bindings)
accidentally produces the same effect as the _reset_all() API that we
are about to add.

Add the standard precondition checks to prevent that from happening.

https://bugzilla.gnome.org/show_bug.cgi?id=744678
2016-07-16 22:26:43 -04:00
Marc-Antoine Perennou
5cea1c861d gsettings: add get/set_{,u}int64
https://bugzilla.gnome.org/show_bug.cgi?id=755898

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2016-04-28 17:28:44 +02:00
Matthias Clasen
9acd0ddbf3 gio: Intern all signal names beforehand
This avoids pointless copying of static strings.
2015-09-12 11:13:45 -04:00
Matthias Clasen
1dec512a66 Revert "GSettings: delay backend subscription"
This reverts commit 8ff5668a45.

This change has had considerable fallout, and there was no
follow-up to address it.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2015-09-01 10:21:26 -04:00
Matthias Clasen
7fff264777 Revert "GSettings: fix check for delaying backend subscription"
This reverts commit d511d6b37f.
2015-09-01 10:18:23 -04:00
Philip Withnall
6cd1f8b40f gsettings: Document GSettings build system integration
Add a new section to the main GSettings documentation which documents
the best practices for integrating GSettings into an autoconf/automake
build system using the GLIB_GSETTINGS macro.

Some of this material was adapted from the migrating-gconf.xml guide.

https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-09 08:28:00 +01:00
Philip Withnall
723961b749 gsettings: Expand documentation default value l10n
Mention context, translation category, and the need for syntactic
validity of the translated values.

https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-09 08:28:00 +01:00
Ryan Lortie
82fcfeb3b0 GSettingsSchema: add g_settings_schema_list_keys()
The list of keys in a GSettings object depends entirely on the schema,
so it makes sense to expose this API there.

Move the implementation out of gsettings.c and into gsettingsschema.c,
replacing the earlier with a simple call to the new location.

We don't do the same for children because the children can change.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:24:02 -04:00
Philip Withnall
c94e4c6f03 gsettings: Add a documentation section on relocatable schemas
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-05 13:02:33 +01:00
Rico Tzschichholz
eb92b4fdff gio: Add some missing type annotations to object arguments
Similar to https://bugzilla.gnome.org/show_bug.cgi?id=745239
2015-03-01 18:12:09 +01:00
Xavier Claessens
74c22150cf docs: fix up docs issues in gio/ 2015-02-05 16:20:43 +01:00
Ryan Lortie
7417198e4e docs: fix typo in g_settings_new_full() docstring 2015-02-04 16:30:24 +01:00
Lars Uebernickel
6d55189d8c gsettings: add g_settings_schema_list_children
https://bugzilla.gnome.org/show_bug.cgi?id=743517
2015-01-28 18:09:28 +00:00
Philip Withnall
70e2630f5a gsettings: Fix a typo in the GSettings documentation
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-01-14 10:53:04 +00:00
Erick Pérez Castellanos
8344bf1179 Fix document typo
This one was making syntax highlighting fail.
2014-12-22 11:02:08 -05:00
Lars Uebernickel
d511d6b37f GSettings: fix check for delaying backend subscription
g_settings_has_signal_handlers() checks whether any of the signals has
pending handlers. However, g_signal_has_handler_pending() matches on
exact detail, even when passing 0. Subscribing to one of GSettings'
signals with a detail will fail this check and never connect to the
backend.

Fix this by calling has_handler_pending() with the key as detail as
well.

https://bugzilla.gnome.org/show_bug.cgi?id=740848
2014-11-28 15:19:07 +01:00
Ryan Lortie
8ff5668a45 GSettings: delay backend subscription
GSettings objects begin watching for changes as soon as they are created
in order that they can emit the "changed" signal.

In the case of dconf, if we want to be able to emit the changed signal,
we need to go on the bus and add some match rules.  This requires
creating the dconf helper thread and also requires initialising GDBus
(which creates another thread).

Some users of GSettings are never interested in the "changed" signal.
One of these users is the glib-networking code that gets run every time
a new network connection is created.

Some users are reporting that they are annoyed that simply establishing
a network connection would spawn two extra threads and create a D-Bus
connection.

In order to avoid doing unnecessary work for these simple uses, delay
the subscription until we know that we will actually need to do it.

We do this in a simple way, using a simple argument: in order for the
user to care that a value changed then they must have:

 1) watched for a change signal; and then
 2) actually read a value

If the user didn't actually read a value then they cannot possibly be
interested in if the value changed or not (since they never knew the old
value to begin with and therefore would be unable to observe that it
ever changed, since they have nothing to compare the new value with).

This really is a behaviour change, however, and it does impact at least
one user: the 'monitor' functionality of the GSettings commandline tool,
which is interested in reporting changes without ever having known the
original values.  We add a workaround to the commandline tool in order
to ensure that it continues to function properly.

It's also possible to argue that it is completely valid to have read a
value and _then_ established a change signal connection under the
(correct) assumption that it would not have been possible to miss a
change signal by virtue of not having returned to the mainloop.
Although this argument is true, this pattern is extremely non-idiomatic,
and the problem is easily avoided by doing things in the usual order.

We never really talked about change notification in the overview
documentation for GSettings, so it seems like now is a good time to add
some discussion, including the new rules for when one can expect change
signals to be emitted.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2014-11-19 13:40:09 -05:00
Ryan Lortie
59c9291f5f Revert "gsettings: remove long-deprecated "schema" property"
This reverts commit cf9b162e0d.

It turns out that there are still a very large number of users of this
API.

https://bugzilla.gnome.org/show_bug.cgi?id=732102
2014-06-24 16:57:12 -04:00
Ryan Lortie
cf9b162e0d gsettings: remove long-deprecated "schema" property
This property has been deprecated for three years after only having
existed for one.  We've wanted to reuse the name for all that time, so
let's try to actually remove it now and see if we can get away with it.

https://bugzilla.gnome.org/show_bug.cgi?id=732102
2014-06-24 14:18:28 -04:00
Ryan Lortie
698970f1f7 gsettingsbackend: a minor simplification
Change the order of the arguments on the (internal) keys_changed callback in
GSettingsListenerVTable.

This means that all functions in the table now fit the following signature:

  void (* f) (GObject             *target,
              GSettingsBackend    *backend,
              const gchar         *name_or_path,
              gpointer             origin_tag,
              const gchar * const *names);

allowing the possibility of arguments ignored at the end.

This allows us to simplify our dispatch-to-thread code in GSettingsBackend,
making it a bit less generic.

So far, this should be a straight refactor.

https://bugzilla.gnome.org/show_bug.cgi?id=710367
2014-03-14 09:46:39 -04:00
Matthias Clasen
35066ed6c6 Docs: Drop entities, switch away from sgml mode
Since all element markup is now gone from the doc comments,
we can turn off the gtk-doc sgml mode, which means that from
now on, docbook markup is no longer allowed in doc comments.

To make this possible, we have to replace all remaining
entities in doc comments by their replacement text, &amp; -> &
and so on.
2014-02-09 02:07:26 -05:00
Matthias Clasen
e7fd3de86d Eradicate links and xrefs
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
df990914cf Stop using replaceable tags 2014-02-06 16:49:29 -05:00
Matthias Clasen
4569b8ac2d Stop using starttag elements 2014-02-06 08:07:15 -05:00
Matthias Clasen
cb588d4532 Convert external links to markdown syntax 2014-02-05 21:23:28 -05:00
Matthias Clasen
0cc20b7e0b Don't use <filename> in docs
Switch to simpler markdown, `foo`.
2014-02-05 20:17:46 -05:00
Matthias Clasen
95aba90d09 Docs: Remove another use of xinclude 2014-02-01 20:41:12 -05:00
Matthias Clasen
42cf80780b Docs: Big entity cleanup
Strip lots of entity use from |[ ]| examples (which are now
implicit CDATA). Also remove many redundant uses of <!-- -->.
2014-02-01 12:00:30 -05:00
Matthias Clasen
eb69bc6aa4 GSettings: use markdown for sections 2014-02-01 10:48:02 -05:00
Matthias Clasen
17f51583a8 Docs: Convert examples to |[ ]| 2014-01-31 21:56:33 -05:00
Matthias Clasen
4d12e0d66f Docs: Don't use the emphasis tag
Most of the time, the text read just as well without the extra
boldness.
2014-01-31 20:34:33 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Jasper St. Pierre
ea22300620 gsettings: Fix annotations 2014-01-21 12:00:41 -05:00
Matthias Clasen
3872049445 Add includes to all gio docs 2014-01-07 22:55:43 -05:00