Skip to contentSkip to conversation

ui: fix keymap file search in input-barrier object

PATCH In review Laurent Vivier 2 participants 3 messages Sep 23, 2019 – Oct 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui: fix keymap file search in input-barrier object

If we try to start QEMU with "-k en-us", qemu prints a message and exits with:

qemu-system-i386: could not read keymap file: 'en-us'

It's because this function is called way too early, before qemu_add_data_dir() is called, and so qemu_find_file() fails.

To fix that, move init_keyboard_layout() from the class init function to the instance init function.

Fixes 6105683da35b ("ui: add an embedded Barrier client")
---
 ui/input-barrier.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
ui/input-barrier.c +7 -7
index a2c961f285a4..fe35049b83a2 100644
@@ -682,6 +682,13 @@ static void input_barrier_instance_init(Object *obj)
 {
     InputBarrier *ib = INPUT_BARRIER(obj);
 
+    /* always use generic keymaps */
+    if (keyboard_layout && !kbd_layout) {
+        /* We use X11 key id, so use VNC name2keysym */
+        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
+                                          &error_fatal);
+    }
+
     ib->saddr.type = SOCKET_ADDRESS_TYPE_INET;
     ib->saddr.u.inet.host = g_strdup("localhost");
     ib->saddr.u.inet.port = g_strdup("24800");
@@ -719,13 +726,6 @@ static void input_barrier_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = input_barrier_complete;
-
-    /* always use generic keymaps */
-    if (keyboard_layout) {
-        /* We use X11 key id, so use VNC name2keysym */
-        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
-                                          &error_fatal);
-    }
 }
 
 static const TypeInfo input_barrier_info = {
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Laurent Vivier

If we try to start QEMU with "-k en-us", qemu prints a message and exits with:

qemu-system-i386: could not read keymap file: 'en-us'

It's because this function is called way too early, before qemu_add_data_dir() is called, and so qemu_find_file() fails.

Quoted 6 lines

To fix that, move init_keyboard_layout() from the class init function to the instance init function.

Fixes 6105683da35b ("ui: add an embedded Barrier client")

Thanks!

With the patch apply, I can start QEMU (with -k).
And the patch looks fine.

Signature · 1 line
Anthony PERARD
#2 lore raw
In reply to Laurent Vivier

Ping?

Le 24/09/2019 à 00:06, Laurent Vivier a écrit :

Quoted 51 lines

If we try to start QEMU with "-k en-us", qemu prints a message and exits with:

qemu-system-i386: could not read keymap file: 'en-us'

It's because this function is called way too early, before qemu_add_data_dir() is called, and so qemu_find_file() fails.

To fix that, move init_keyboard_layout() from the class init function to the instance init function.

Fixes 6105683da35b ("ui: add an embedded Barrier client")
---
 ui/input-barrier.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
ui/input-barrier.c +7 -7
index a2c961f285a4..fe35049b83a2 100644
@@ -682,6 +682,13 @@ static void input_barrier_instance_init(Object *obj)
 {
     InputBarrier *ib = INPUT_BARRIER(obj);
 
+    /* always use generic keymaps */
+    if (keyboard_layout && !kbd_layout) {
+        /* We use X11 key id, so use VNC name2keysym */
+        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
+                                          &error_fatal);
+    }
+
     ib->saddr.type = SOCKET_ADDRESS_TYPE_INET;
     ib->saddr.u.inet.host = g_strdup("localhost");
     ib->saddr.u.inet.port = g_strdup("24800");
@@ -719,13 +726,6 @@ static void input_barrier_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = input_barrier_complete;
-
-    /* always use generic keymaps */
-    if (keyboard_layout) {
-        /* We use X11 key id, so use VNC name2keysym */
-        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
-                                          &error_fatal);
-    }
 }
 
 static const TypeInfo input_barrier_info = {