From 8f6e599c5f886f21394d4c8543c30952df56501f Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Tue, 24 Jun 2014 14:45:03 +0000 Subject: 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. --- 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!') diff --git a/game.py b/game.py index fc4080b..699936d 100644 --- a/game.py +++ b/game.py @@ -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) -- cgit v0.9.1