[gnome-games] ui: Don't store runners anymore in ApplicationWindow



commit a0fdd3f67a2568ba8e12dbd40e2108fee7fe957f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Aug 17 06:44:58 2016 +0200

    ui: Don't store runners anymore in ApplicationWindow
    
    This avoids keeping unused runners, which is useless, make use of more
    memory.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770004

 src/ui/application-window.vala |   33 ++++-----------------------------
 1 files changed, 4 insertions(+), 29 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 8547274..192b2dc 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -73,12 +73,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        private Binding header_bar_search_binding;
        private Binding header_bar_fullscreen_binding;
 
-       private HashTable<Game, Runner> runners;
-
-       // These allow to cancel dialogs.
-       // They are usefull when trying to run a game or to quit the
-       // application from an external source (the application menu, the
-       // command line...).
        private Cancellable run_game_cancellable;
        private Cancellable quit_game_cancellable;
 
@@ -87,8 +81,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        construct {
-               runners = new HashTable<Game, Runner> (GLib.direct_hash, GLib.direct_equal);
-
                box_search_binding = bind_property ("search-mode", collection_box, "search-mode",
                                                    BindingFlags.BIDIRECTIONAL);
                header_bar_search_binding = bind_property ("search-mode", collection_header_bar, 
"search-mode",
@@ -200,7 +192,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
        private Runner? try_get_runner (Game game) {
                try {
-                       return get_runner_for_game (game);
+                       var runner = game.get_runner ();
+                       runner.check_is_valid ();
+
+                       return runner;
                }
                catch (Error e) {
                        warning ("%s\n", e.message);
@@ -314,24 +309,4 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                return false;
        }
-
-       private Runner get_runner_for_game (Game game) throws Error {
-               if (runners.contains (game))
-                       return runners[game];
-
-               var runner = game.get_runner ();
-               runner.check_is_valid ();
-               runners[game] = runner;
-
-               runner.stopped.connect (remove_runner);
-
-               return runner;
-       }
-
-       private void remove_runner (Runner runner) {
-               foreach (var game in runners.get_keys ()) {
-                       if (runners[game] == runner)
-                               runners.remove (game);
-               }
-       }
 }


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