[four-in-a-row/KaKnife/four-in-a-row-vala: 65/65] prefs-box: Clean up hidden variable warning



commit 3d9da824a0c3ba7eb23969786bc7e07eb08b7907
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Dec 15 21:12:20 2018 -0600

    prefs-box: Clean up hidden variable warning
    
    prefs-box.vala:26.5-26.26: warning: PrefsBox.application hides inherited field `Gtk.Window.application'. 
Use the `new' keyword if hiding was intentional
        FourInARow application;
        ^^^^^^^^^^^^^^^^^^^^^^
    
    No need to store the FourInARow application manually here: we already
    have it. Further note that it was never set, so the existing code must
    have been broken.

 src/four-in-a-row.vala | 2 +-
 src/prefs-box.vala     | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index 2ca4de8..47a6058 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -785,7 +785,7 @@ class FourInARow : Gtk.Application {
             return;
         }
 
-        prefsbox = new PrefsBox(window, this);
+        prefsbox = new PrefsBox(window);
         prefsbox.show_all();
     }
 }
diff --git a/src/prefs-box.vala b/src/prefs-box.vala
index 81e88d9..890ecfc 100644
--- a/src/prefs-box.vala
+++ b/src/prefs-box.vala
@@ -23,9 +23,8 @@ class PrefsBox : Gtk.Dialog {
     Gtk.ComboBox combobox;
     Gtk.ComboBoxText combobox_theme;
     Gtk.ToggleButton checkbutton_sound;
-    FourInARow application;
 
-    public PrefsBox(Gtk.Window parent, FourInARow application) {
+    public PrefsBox(Gtk.Window parent) {
         Gtk.Grid grid;
         GamesControlsList controls_list;
         Gtk.Label label;
@@ -133,6 +132,7 @@ class PrefsBox : Gtk.Dialog {
     }
 
     void on_select_opponent(Gtk.ComboBox w) {
+        FourInARow app = (FourInARow)application;
         Gtk.TreeIter iter;
         int value;
 
@@ -141,7 +141,7 @@ class PrefsBox : Gtk.Dialog {
 
         Prefs.instance.level[PlayerID.PLAYER2] = (Level)value;
         Prefs.instance.settings.set_int("opponent", value);
-        application.who_starts = PlayerID.PLAYER2; /* This gets reversed in game_reset. */
-        application.game_reset();
+        app.who_starts = PlayerID.PLAYER2; /* This gets reversed in game_reset. */
+        app.game_reset();
     }
 }


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