[PATCH] Prevent crashes due to accessing X server from multiple threads

David Shea dshea at redhat.com
Thu Jul 17 17:21:23 UTC 2014


On 07/17/2014 10:20 AM, Vratislav Podzimek wrote:
> Gdk and Xklavier both access the X server, so we have to make sure those calls
> happen from a single thread (the main loop one).
>
> Make the join_layout_variant function public now that it is used from a
> different module.
>
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>   anaconda                                |   2 -
>   pyanaconda/keyboard.py                  | 371 +------------------------------
>   pyanaconda/ui/gui/spokes/keyboard.py    |   9 +-
>   pyanaconda/ui/gui/spokes/welcome.py     |   3 +-
>   pyanaconda/ui/gui/xkl_wrapper.py        | 383 ++++++++++++++++++++++++++++++++
>   tests/pyanaconda_tests/keyboard_test.py |   6 +-
>   6 files changed, 400 insertions(+), 374 deletions(-)
>   create mode 100644 pyanaconda/ui/gui/xkl_wrapper.py
>

> diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
> index f76fa84..3c4d351 100644
> --- a/pyanaconda/ui/gui/spokes/keyboard.py
> +++ b/pyanaconda/ui/gui/spokes/keyboard.py
> @@ -26,6 +26,7 @@ from pyanaconda.ui.gui import GUIObject
>   from pyanaconda.ui.gui.spokes import NormalSpoke
>   from pyanaconda.ui.categories.localization import LocalizationCategory
>   from pyanaconda.ui.gui.utils import gtk_call_once, escape_markup, gtk_batch_map, timed_action
> +from pyanaconda.ui.gui.xkl_wrapper import XklWrapper
>   from pyanaconda import keyboard
>   from pyanaconda import flags
>   from pyanaconda.i18n import _, N_, CN_
> @@ -65,7 +66,7 @@ class AddLayoutDialog(GUIObject):
>   
>       def __init__(self, *args):
>           GUIObject.__init__(self, *args)
> -        self._xkl_wrapper = keyboard.XklWrapper.get_instance()
> +        self._xkl_wrapper = XklWrapper.get_instance()
>           self._chosen_layouts = []
>   
>       def matches_entry(self, model, itr, user_data=None):
> @@ -184,7 +185,7 @@ class ConfigureSwitchingDialog(GUIObject):
>   
>       def __init__(self, *args):
>           GUIObject.__init__(self, *args)
> -        self._xkl_wrapper = keyboard.XklWrapper.get_instance()
> +        self._xkl_wrapper = XklWrapper.get_instance()
>   
>           self._switchingOptsStore = self.builder.get_object("switchingOptsStore")
>   
> @@ -273,7 +274,7 @@ class KeyboardSpoke(NormalSpoke):
>           NormalSpoke.__init__(self, *args)
>           self._remove_last_attempt = False
>           self._confirmed = False
> -        self._xkl_wrapper = keyboard.XklWrapper.get_instance()
> +        self._xkl_wrapper = XklWrapper.get_instance()
>           self._add_dialog = None
>           self._ready = False
>   
> @@ -607,7 +608,7 @@ class KeyboardSpoke(NormalSpoke):
>               try:
>                   self._addLayout(self._store, layout)
>                   valid_layouts += layout
> -            except keyboard.XklWrapperError:
> +            except XklWrapperError:
>                   log.error("Failed to add layout '%s'", layout)

The exception needs to be imported from xkl_wrapper.

Other than that and Martin's comment, it looks good to me.


More information about the anaconda-patches mailing list