[gnome-boxes/release-gnome-3-32-2: 4/5] unnatended-installer: Guard get_preferred_kbd_lang with try/catch
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/release-gnome-3-32-2: 4/5] unnatended-installer: Guard get_preferred_kbd_lang with try/catch
- Date: Thu, 5 Sep 2019 14:26:45 +0000 (UTC)
commit c5bcbc7fa5e63c911a2b8c4c0d65c4f9899b804a
Author: Felipe Borges <felipeborges gnome org>
Date: Mon Jun 3 15:36:06 2019 +0200
unnatended-installer: Guard get_preferred_kbd_lang with try/catch
We shouldn't crash when the GSetting is not available. Instead we
should map the user language to the libosinfo datamap and go with
it. That's not 100% ideal because some users have a language which
doesn't match their keyboard layout, but it is better than
arbitrarialy setting en_US or crashing.
src/unattended-installer.vala | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 8f12b2de..d02dabcc 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -703,18 +703,24 @@ else if (compatibility == CPUArchCompatibility.COMPATIBLE && drivers.lookup (loc
}
private string get_preferred_keyboard (string lang) {
- var input_settings = new GLib.Settings ("org.gnome.desktop.input-sources");
- var sources = input_settings.get_value ("sources");
-
- string kbd_layout = null;
- if (sources != null)
- kbd_layout = sources.get_child_value (0).get_child_value (1).get_string ();
-
var os_db = MediaManager.get_instance ().os_db;
var datamap = os_db.get_datamap ("http://x.org/x11-keyboard");
+ string kbd_layout = null;
- if (datamap.reverse_lookup (kbd_layout) != null)
- return kbd_layout;
+ try {
+ var input_settings = new GLib.Settings ("org.gnome.desktop.input-sources");
+ var sources = input_settings.get_value ("sources");
+
+ if (sources != null) {
+ kbd_layout = sources.get_child_value (0).get_child_value (1).get_string ();
+ }
+
+ if (datamap.reverse_lookup (kbd_layout) != null) {
+ return kbd_layout;
+ }
+ } catch (GLib.Error error) {
+ warning (error.message);
+ }
kbd_layout = datamap.lookup (lang);
if (kbd_layout != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]