linux: Also check for schema before init
This commit is contained in:
parent
f6ff97cbeb
commit
fe3489b383
1 changed files with 13 additions and 2 deletions
|
@ -16,6 +16,16 @@ namespace {
|
||||||
const char* kInterfaceSchema = "org.gnome.desktop.interface";
|
const char* kInterfaceSchema = "org.gnome.desktop.interface";
|
||||||
const char* kScaleFactor = "scaling-factor";
|
const char* kScaleFactor = "scaling-factor";
|
||||||
|
|
||||||
|
bool SchemaExists(const LibGioLoader& libgio_loader, const char* schema_name) {
|
||||||
|
const gchar* const* schemas = libgio_loader.g_settings_list_schemas();
|
||||||
|
while (*schemas) {
|
||||||
|
if (strcmp(schema_name, static_cast<const char*>(*schemas)) == 0)
|
||||||
|
return true;
|
||||||
|
schemas++;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void GetDPIFromGSettings(guint* scale_factor) {
|
void GetDPIFromGSettings(guint* scale_factor) {
|
||||||
LibGioLoader libgio_loader;
|
LibGioLoader libgio_loader;
|
||||||
|
|
||||||
|
@ -26,8 +36,9 @@ void GetDPIFromGSettings(guint* scale_factor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSettings* client = libgio_loader.g_settings_new(kInterfaceSchema);
|
GSettings* client = nullptr;
|
||||||
if (!client) {
|
if (!SchemaExists(libgio_loader, kInterfaceSchema) ||
|
||||||
|
!(client = libgio_loader.g_settings_new(kInterfaceSchema))) {
|
||||||
VLOG(1) << "Cannot create gsettings client.";
|
VLOG(1) << "Cannot create gsettings client.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue