After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620642 - GSettings should implement GInitable
GSettings should implement GInitable
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-06-05 10:59 UTC by Christian Persch
Modified: 2011-05-29 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make GSettings implement GInitable (23.14 KB, patch)
2010-06-05 11:33 UTC, Christian Persch
none Details | Review
alternative patch (9.56 KB, patch)
2010-06-05 11:59 UTC, Christian Persch
none Details | Review

Description Christian Persch 2010-06-05 10:59:00 UTC
The GSettings construction will just call g_error() if something goes wrong, e.g. in g_settings_schema_new() if the schema isn't found in the cache. 

IMHO GSettings should instead implement GInitable (and GAsyncInitable, wrt. bug 620641) so one can instead get NULL + a GError back.
Comment 1 Christian Persch 2010-06-05 11:33:54 UTC
Created attachment 162794 [details] [review]
Make GSettings implement GInitable

Proof of concept patch.
TODO: Needs a new public GSettingsError enum, and an error domain,
to return gsettings specific errors.

Bug #620642.
Comment 2 Christian Persch 2010-06-05 11:36:46 UTC
Alternatively, if you don't want to change the signature of g_settings_new* at this point, instead of adding a GError param, these convenience constructors could just g_assert that construction succeeded; and if you need to check yourself, you can just use g_initable_new directly yourself.
Comment 3 Christian Persch 2010-06-05 11:59:27 UTC
Created attachment 162800 [details] [review]
alternative patch

Alternative patch which doesn't change the public g_settings_new* constructors. (I like the original patch better though.)
Comment 4 Allison Karlitskaya (desrt) 2010-06-07 13:37:03 UTC
this is really too much.

For the use case we discussed on IRC I will probably just add a:

bool g_settings_exists(string schema_name);

sort of thing
Comment 5 ecyrbe 2011-05-29 12:21:30 UTC
This patch has a bug, you forget to check the result of
g_settings_schema_new in g_settings_constructed