63 lines
2.2 KiB
Diff
63 lines
2.2 KiB
Diff
|
From 51669cb03613b36b0b1798b1f8d2bba85b3e2a49 Mon Sep 17 00:00:00 2001
|
||
|
From: Martin Pitt <martin.pitt@ubuntu.com>
|
||
|
Date: Mon, 18 Jan 2010 16:09:58 +0100
|
||
|
Subject: [PATCH] Fix crash in getting system keyboard layout
|
||
|
|
||
|
In get_system_default_layout(), use a static variable for
|
||
|
xkl_engine_get_instance() result, and don't close the X Display.
|
||
|
|
||
|
This fixes the crash that happens at the second call of
|
||
|
get_system_default_layout(): xkl_engine_get_instance() returns a singleton
|
||
|
which saves the passed X Display instance, so we must never close it.
|
||
|
|
||
|
https://launchpad.net/bugs/505972
|
||
|
---
|
||
|
daemon/gdm-session-direct.c | 23 ++++++++++++-----------
|
||
|
1 files changed, 12 insertions(+), 11 deletions(-)
|
||
|
|
||
|
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
|
||
|
index 011a919..d2e1a83 100644
|
||
|
--- a/daemon/gdm-session-direct.c
|
||
|
+++ b/daemon/gdm-session-direct.c
|
||
|
@@ -601,16 +601,19 @@ get_default_language_name (GdmSessionDirect *session)
|
||
|
static char *
|
||
|
get_system_default_layout (GdmSessionDirect *session)
|
||
|
{
|
||
|
- char *result;
|
||
|
- Display *display;
|
||
|
+ char *result = NULL;
|
||
|
+ static XklEngine *engine = NULL;
|
||
|
|
||
|
- result = NULL;
|
||
|
- display = XOpenDisplay (session->priv->display_name);
|
||
|
- if (display) {
|
||
|
- XklConfigRec *config;
|
||
|
- XklEngine *engine = xkl_engine_get_instance (display);
|
||
|
- if (engine)
|
||
|
- {
|
||
|
+ if (engine == NULL) {
|
||
|
+ Display *display = XOpenDisplay (session->priv->display_name);
|
||
|
+ if (display != NULL) {
|
||
|
+ engine = xkl_engine_get_instance (display);
|
||
|
+ }
|
||
|
+ /* do NOT call XCloseDisplay (display) here;
|
||
|
+ * xkl_engine_get_instance() is a singleton which saves the display */
|
||
|
+ }
|
||
|
+
|
||
|
+ if (engine != NULL) {
|
||
|
XklConfigRec *config = xkl_config_rec_new ();
|
||
|
if (xkl_config_rec_get_from_server (config, engine) && config->layouts && config->layouts[0]) {
|
||
|
if (config->variants && config->variants[0] && config->variants[0][0])
|
||
|
@@ -619,8 +622,6 @@ get_system_default_layout (GdmSessionDirect *session)
|
||
|
result = g_strdup (config->layouts[0]);
|
||
|
}
|
||
|
g_object_unref (config);
|
||
|
- }
|
||
|
- XCloseDisplay (display);
|
||
|
}
|
||
|
|
||
|
if (!result)
|
||
|
--
|
||
|
1.6.6
|
||
|
|