[gnome-games/wip/exalm/subprocess: 11/11] display-view: Handle runner crashes
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/subprocess: 11/11] display-view: Handle runner crashes
- Date: Sun, 2 Feb 2020 16:50:57 +0000 (UTC)
commit a70233ab1636bbaf61c5f8afad012aacf4579c02
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Jan 10 18:58:29 2020 +0500
display-view: Handle runner crashes
src/core/runner.vala | 1 +
src/retro/retro-runner.vala | 18 ++++++++++++++----
src/ui/display-box.vala | 7 +++++++
src/ui/display-view.vala | 26 +++++++++++++++++++++++++-
4 files changed, 47 insertions(+), 5 deletions(-)
---
diff --git a/src/core/runner.vala b/src/core/runner.vala
index 1bedceca..83b4e3b2 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -3,6 +3,7 @@
public interface Games.Runner : Object {
public signal void new_savestate_created ();
public signal void stopped ();
+ public signal void crash (string message);
public abstract bool can_fullscreen { get; }
public abstract bool can_resume { get; }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 126c47e4..540c9989 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -62,6 +62,7 @@ public class Games.RetroRunner : Object, Runner {
private bool is_initialized;
private bool is_ready;
+ private bool is_error;
public RetroRunnerBuilder builder {
construct {
@@ -275,6 +276,10 @@ public class Games.RetroRunner : Object, Runner {
_input_mode = input_manager.input_mode;
core.shutdown.connect (stop);
+ core.crashed.connect ((core, error) => {
+ is_error = true;
+ crash (error);
+ });
running = false;
@@ -288,8 +293,11 @@ public class Games.RetroRunner : Object, Runner {
settings.changed["video-filter"].disconnect (on_video_filter_changed);
core = null;
- view.set_core (null);
- view = null;
+
+ if (view != null) {
+ view.set_core (null);
+ view = null;
+ }
input_manager = null;
@@ -355,8 +363,10 @@ public class Games.RetroRunner : Object, Runner {
if (!running)
return;
- current_state_pixbuf = view.get_pixbuf ();
- core.stop ();
+ if (!is_error) {
+ current_state_pixbuf = view.get_pixbuf ();
+ core.stop ();
+ }
//FIXME:
// In the future here there will be code which updates the currently
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 45db5c9a..261faf1f 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -4,6 +4,7 @@
private class Games.DisplayBox : Gtk.Bin {
public signal void back ();
public signal void snapshots_hidden ();
+ public signal void restart ();
private bool _is_fullscreen;
public bool is_fullscreen {
@@ -78,6 +79,12 @@ private class Games.DisplayBox : Gtk.Bin {
error_display.running_game_failed (game, error_message);
}
+ public void display_game_crashed (Game game, string error_message) {
+ stack.visible_child = error_display;
+ is_showing_snapshots = false;
+ error_display.game_crashed (game, error_message);
+ }
+
[GtkCallback]
private void on_fullscreen_header_bar_back () {
back ();
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index e7421ee3..5c08a753 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -57,6 +57,7 @@ private class Games.DisplayView : Object, UiView {
private QuitDialog quit_dialog;
private long focus_out_timeout_id;
+ private Game game;
private SimpleActionGroup action_group;
private const ActionEntry[] action_entries = {
@@ -164,6 +165,9 @@ private class Games.DisplayView : Object, UiView {
}
// Shortcuts for the Savestates manager
+ if (runner == null)
+ return false;
+
if (!runner.supports_savestates)
return false;
@@ -284,6 +288,8 @@ private class Games.DisplayView : Object, UiView {
if (runner != null && !quit_game ())
return;
+ this.game = game;
+
if (run_game_cancellable != null)
run_game_cancellable.cancel ();
@@ -312,6 +318,19 @@ private class Games.DisplayView : Object, UiView {
header_bar.media_set = runner.media_set;
box.header_bar.media_set = runner.media_set;
+ runner.crash.connect (message => {
+ runner.stop ();
+ reset_display_page ();
+
+ if (run_game_cancellable != null)
+ run_game_cancellable.cancel ();
+
+ if (quit_game_cancellable != null)
+ quit_game_cancellable.cancel ();
+
+ box.display_game_crashed (game, message);
+ });
+
update_actions ();
is_fullscreen = settings.get_boolean ("fullscreen") && can_fullscreen;
@@ -585,7 +604,12 @@ private class Games.DisplayView : Object, UiView {
}
private void restart () {
- if (runner != null && runner.is_integrated)
+ if (runner != null && runner.is_integrated) {
runner.restart ();
+ return;
+ }
+
+ if (game != null)
+ run_game (game);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]