Skip to content

Commit

Permalink
gdkkeys: Avoid instantiating a display manager if none exists
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cgwalters committed Mar 23, 2013
1 parent 564b4e6 commit d6b4e84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions gdk/gdkdisplaymanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ gdk_set_allowed_backends (const gchar *backends)
allowed_backends = g_strdup (backends);
}

static GdkDisplayManager *manager = NULL;

/**
* gdk_display_manager_get:
*
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions gdk/gdkdisplaymanagerprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ struct _GdkDisplayManagerClass
GdkDisplay *display);
};

GdkDisplayManager *
_gdk_display_manager_get_nocreate (void);

G_END_DECLS

#endif
7 changes: 5 additions & 2 deletions gdk/gdkkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit d6b4e84

Please sign in to comment.