eekboard-context-service: Return early if schema is unavailable

This also fixes a leak of GSettingsSchema.
This commit is contained in:
Guido Günther
2020-09-11 15:51:58 +02:00
parent 2f4a652f53
commit c26feed8b2

View File

@ -244,10 +244,14 @@ eekboard_context_service_init (EekboardContextService *self)
self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self); self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self);
const char *schema_name = "org.gnome.desktop.input-sources"; const char *schema_name = "org.gnome.desktop.input-sources";
GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default(); GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
if (ssrc) { g_autoptr(GSettingsSchema) schema = NULL;
GSettingsSchema *schema = g_settings_schema_source_lookup(ssrc,
schema_name, if (!ssrc) {
TRUE); g_warning("No gsettings schemas installed. Layout switching unavailable.");
return;
}
schema = g_settings_schema_source_lookup(ssrc, schema_name, TRUE);
if (schema) { if (schema) {
// Not referencing the found schema directly, // Not referencing the found schema directly,
// because it's not clear how... // because it's not clear how...
@ -263,9 +267,6 @@ eekboard_context_service_init (EekboardContextService *self)
g_warning("Gsettings schema %s is not installed on the system. " g_warning("Gsettings schema %s is not installed on the system. "
"Layout switching unavailable", schema_name); "Layout switching unavailable", schema_name);
} }
} else {
g_warning("No gsettings schemas installed. Layout switching unavailable.");
}
} }
/** /**