[gnome-games/wip/exalm/crash] retro-runner: Always set platform when creating from a CoreDescriptor



commit ce5b45a9e3d9c684fda32f84699c5c41fb75d2c1
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Nov 15 23:52:35 2018 +0500

    retro-runner: Always set platform when creating from a CoreDescriptor

 plugins/libretro/src/libretro-plugin.vala |  2 +-
 src/retro/retro-runner.vala               | 31 ++++++++++++++-----------------
 2 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index e12737da..4bba2b65 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -39,7 +39,7 @@ private class Games.LibretroPlugin : Object, Plugin {
                var uid = new LibretroUid (core_descriptor);
                var title = new LibretroTitle (core_descriptor);
                var icon = new LibretroIcon (core_descriptor);
-               var runner = new RetroRunner.for_core_descriptor (core_descriptor, uid, title);
+               var runner = new RetroRunner.for_core_descriptor_and_platform (core_descriptor, platform, 
uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 3d59ad72..2739d6df 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -46,6 +46,7 @@ public class Games.RetroRunner : Object, Runner {
 
        private Retro.CoreDescriptor core_descriptor;
        private RetroCoreSource core_source;
+       private Platform platform;
        private Uid uid;
        private InputCapabilities input_capabilities;
        private Settings settings;
@@ -81,6 +82,7 @@ public class Games.RetroRunner : Object, Runner {
 
                this.uid = uid;
                this.core_source = core_source;
+               this.platform = core_source.get_platform ();
                this.input_capabilities = null;
                this.game_title = game_title;
        }
@@ -92,6 +94,7 @@ public class Games.RetroRunner : Object, Runner {
 
                this.core_descriptor = null;
                this.core_source = core_source;
+               this.platform = core_source.get_platform ();
                this._media_set = media_set;
                this.uid = uid;
                this.input_capabilities = input_capabilities;
@@ -100,13 +103,14 @@ public class Games.RetroRunner : Object, Runner {
                _media_set.notify["selected-media-number"].connect (on_media_number_changed);
        }
 
-       public RetroRunner.for_core_descriptor (Retro.CoreDescriptor core_descriptor, Uid uid, Title 
game_title) {
+       public RetroRunner.for_core_descriptor_and_platform (Retro.CoreDescriptor core_descriptor, Platform 
platform, Uid uid, Title game_title) {
                is_initialized = false;
                is_ready = false;
                should_save = false;
 
                this.core_descriptor = core_descriptor;
                this.core_source = null;
+               this.platform = platform;
                this._media_set = new MediaSet ();
                this.uid = uid;
                this.input_capabilities = null;
@@ -257,16 +261,13 @@ public class Games.RetroRunner : Object, Runner {
                                }
                        });
 
-               if (core_source != null) {
-                       var platforms_dir = Application.get_platforms_dir ();
-                       var platform = core_source.get_platform ();
-                       var platform_id = platform.get_id ();
-                       core.system_directory = @"$platforms_dir/$platform_id/system";
+               var platforms_dir = Application.get_platforms_dir ();
+               var platform_id = platform.get_id ();
+               core.system_directory = @"$platforms_dir/$platform_id/system";
 
-                       var save_directory = get_save_directory_path ();
-                       Application.try_make_dir (save_directory);
-                       core.save_directory = save_directory;
-               }
+               var save_directory = get_save_directory_path ();
+               Application.try_make_dir (save_directory);
+               core.save_directory = save_directory;
 
                core.log.connect (Retro.g_log);
                view.set_core (core);
@@ -533,7 +534,6 @@ public class Games.RetroRunner : Object, Runner {
 
                var now = new GLib.DateTime.now_local ();
                var creation_time = now.to_string ();
-               var platform = core_source.get_platform ();
                var platform_name = platform.get_name ();
                var platform_id = platform.get_id ();
                if (platform_name == null) {
@@ -579,12 +579,9 @@ public class Games.RetroRunner : Object, Runner {
        }
 
        private string get_unsupported_system_message () {
-               if (core_source != null) {
-                       var platform = core_source.get_platform ();
-                       var platform_name = platform.get_name ();
-                       if (platform_name != null)
-                               return _("The system “%s” isn’t supported yet, but full support is 
planned.").printf (platform_name);
-               }
+               var platform_name = platform.get_name ();
+               if (platform_name != null)
+                       return _("The system “%s” isn’t supported yet, but full support is planned.").printf 
(platform_name);
 
                return _("The system isn’t supported yet, but full support is planned.");
        }


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