[gnome-games] retro: Deinit RetroRunner when it is stopped



commit 18b76adeca6aac35011400d1ea19adb8c7ac91c4
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Aug 17 14:01:46 2016 +0200

    retro: Deinit RetroRunner when it is stopped
    
    This will be used in the next commit to release memory when a game will
    stop being used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770004

 src/retro/retro-runner.vala |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index ffdd7e2..3263001 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -168,6 +168,25 @@ public class Games.RetroRunner : Object, Runner {
                is_initialized = true;
        }
 
+       private void deinit () {
+               if (!is_initialized)
+                       return;
+
+               core = null;
+               video = null;
+               audio = null;
+               widget = null;
+               input_manager = null;
+               options = null;
+               log = null;
+               loop = null;
+
+               _running = false;
+               is_initialized = false;
+               is_ready = false;
+               should_save = false;
+       }
+
        private void prepare_core (string module_basename, string uri) throws Error {
                var module_path = get_module_path ();
                core = new Retro.Core (module_path);
@@ -286,6 +305,16 @@ public class Games.RetroRunner : Object, Runner {
                }
        }
 
+       public void stop () {
+               if (!is_initialized)
+                       return;
+
+               pause ();
+               deinit ();
+
+               stopped ();
+       }
+
        private void save () throws Error {
                if (!should_save)
                        return;
@@ -430,8 +459,7 @@ public class Games.RetroRunner : Object, Runner {
        }
 
        private bool on_shutdown () {
-               pause ();
-               stopped ();
+               stop ();
 
                return true;
        }


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