[gnome-games] retro-runner: Reset metadata when starting without existing savestate



commit 761bf4469f919f9f253dae97c74e77d49cd19624
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Mar 2 16:13:06 2020 +0500

    retro-runner: Reset metadata when starting without existing savestate

 plugins/nintendo-ds/src/nintendo-ds-runner.vala | 2 +-
 src/retro/retro-runner.vala                     | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index 6e78b927..83338e3e 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -123,7 +123,7 @@ private class Games.NintendoDsRunner : RetroRunner {
                view_bottom_screen = ds_savestate.view_bottom_screen;
        }
 
-       protected override void reset_metadata (Savestate last_savestate) throws Error {
+       protected override void reset_metadata (Savestate? last_savestate) throws Error {
                base.reset_metadata (last_savestate);
 
                screen_layout = NintendoDsLayout.TOP_BOTTOM;
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 15ab79be..1e3ba88e 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -216,8 +216,7 @@ public class Games.RetroRunner : Object, Runner {
        }
 
        public void start () throws Error {
-               if (latest_savestate != null)
-                       reset_metadata (latest_savestate);
+               reset_metadata (latest_savestate);
 
                if (!is_initialized) {
                        if (latest_savestate != null)
@@ -649,8 +648,8 @@ public class Games.RetroRunner : Object, Runner {
        protected virtual void load_savestate_metadata (Savestate savestate) throws Error {
        }
 
-       protected virtual void reset_metadata (Savestate last_savestate) throws Error {
-               if (last_savestate.has_media_data ())
+       protected virtual void reset_metadata (Savestate? last_savestate) throws Error {
+               if (last_savestate != null && last_savestate.has_media_data ())
                        media_set.selected_media_number = last_savestate.get_media_data ();
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]