GNOME Bugzilla – Bug 620642
GSettings should implement GInitable
Last modified: 2011-05-29 12:21:30 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.
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.
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.
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.)
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
This patch has a bug, you forget to check the result of g_settings_schema_new in g_settings_constructed