diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-06-24 14:45:03 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-06-24 14:45:03 (GMT) |
commit | 8f6e599c5f886f21394d4c8543c30952df56501f (patch) | |
tree | d09a37f134debd2160b7e4f1f81601cce4629950 | |
parent | 74cfa981e36063c0b292b52050362463a524cffe (diff) |
Try avoid crash on change to ebook mode
Some times, Maze crash when change to ebook mode.
I could not find the reason, but looks relatd to the creation
of the alert. As a workaround, execute the alert creation method using
idle_add, and also the buttons in the finish_window do the same.
-rwxr-xr-x | activity.py | 2 | ||||
-rw-r--r-- | game.py | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/activity.py b/activity.py index 6afdbd1..6de6246 100755 --- a/activity.py +++ b/activity.py @@ -143,6 +143,7 @@ class MazeActivity(activity.Activity): self.game.msg_received(buddy, text) def _add_alert(self, title, text=None): + self.grab_focus() self._alert = ErrorAlert() self._alert.props.title = title self._alert.props.msg = text @@ -160,6 +161,7 @@ class MazeActivity(activity.Activity): self._alert.props.msg = text def show_accelerator_alert(self): + self.grab_focus() self._alert = NotifyAlert() self._alert.props.title = _('Tablet mode detected.') self._alert.props.msg = _('Hold your XO flat and tilt to play!') @@ -306,7 +306,7 @@ class MazeGame(Gtk.DrawingArea): def _ebook_mode_changed_cb(self, detector, ebook_mode): if ebook_mode: - self._activity.show_accelerator_alert() + GObject.idle_add(self._activity.show_accelerator_alert) if self._read_accelerator_id is None: self._start_accelerometer() else: @@ -764,7 +764,7 @@ class FinishWindow(Gtk.Window): self.get_window().set_transient_for(self._parent_window_xid) def _easier_button_cb(self, button): - self._game.easier() + GObject.idle_add(self._game.easier) def _harder_button_cb(self, button): - self._game.harder() + GObject.idle_add(self._game.harder) |