[gtk+] gdkkeys: Avoid instantiating a display manager if none exists
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdkkeys: Avoid instantiating a display manager if none exists
- Date: Sat, 23 Mar 2013 21:07:40 +0000 (UTC)
commit d6b4e849578910a354f671d8de09616af7f3ebe1
Author: Colin Walters <walters verbum org>
Date: Sat Mar 23 13:51:24 2013 -0400
gdkkeys: Avoid instantiating a display manager if none exists
For introspection scanning which ends up calling class_init() which in
turn calls into the keybindings code, we can just use the fallback
keyval conversion code.
https://bugzilla.gnome.org/show_bug.cgi?id=696457
gdk/gdkdisplaymanager.c | 13 +++++++++++--
gdk/gdkdisplaymanagerprivate.h | 3 +++
gdk/gdkkeys.c | 7 +++++--
3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index e29fa51..b15aeb0 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -267,6 +267,8 @@ gdk_set_allowed_backends (const gchar *backends)
allowed_backends = g_strdup (backends);
}
+static GdkDisplayManager *manager = NULL;
+
/**
* gdk_display_manager_get:
*
@@ -287,8 +289,6 @@ gdk_set_allowed_backends (const gchar *backends)
GdkDisplayManager*
gdk_display_manager_get (void)
{
- static GdkDisplayManager *manager = NULL;
-
if (manager == NULL)
{
const gchar *backend_list;
@@ -381,6 +381,15 @@ gdk_display_manager_get (void)
return manager;
}
+/* Used for cases where we don't actually want to instantiate a
+ * display manager if none exists. Internal only.
+ */
+GdkDisplayManager *
+_gdk_display_manager_get_nocreate (void)
+{
+ return manager;
+}
+
/**
* gdk_display_manager_get_default_display:
* @manager: a #GdkDisplayManager
diff --git a/gdk/gdkdisplaymanagerprivate.h b/gdk/gdkdisplaymanagerprivate.h
index f915f60..fade4d6 100644
--- a/gdk/gdkdisplaymanagerprivate.h
+++ b/gdk/gdkdisplaymanagerprivate.h
@@ -64,6 +64,9 @@ struct _GdkDisplayManagerClass
GdkDisplay *display);
};
+GdkDisplayManager *
+_gdk_display_manager_get_nocreate (void);
+
G_END_DECLS
#endif
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index 6b46dbf..9194d7f 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -203,9 +203,12 @@ gdk_keyval_convert_case (guint symbol,
guint *lower,
guint *upper)
{
- GdkDisplayManager *manager = gdk_display_manager_get ();
+ GdkDisplayManager *manager = _gdk_display_manager_get_nocreate ();
- GDK_DISPLAY_MANAGER_GET_CLASS (manager)->keyval_convert_case (manager, symbol, lower, upper);
+ if (manager)
+ GDK_DISPLAY_MANAGER_GET_CLASS (manager)->keyval_convert_case (manager, symbol, lower, upper);
+ else
+ _gdk_display_manager_real_keyval_convert_case (NULL, symbol, lower, upper);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]