From 62964e9256fcac616109af874dbb2bd8342a9853 Mon Sep 17 00:00:00 2001
From: Rico Tzschichholz <ricotz@ubuntu.com>
Date: Wed, 17 Mar 2021 11:25:05 +0100
Subject: [PATCH] Reference of [GtkChild] fields is handled by GtkBuilder, type
 must be unowned

---
 src/controls.vala           | 20 ++++++++++----------
 src/nibbles-window.vala     | 26 +++++++++++++-------------
 src/players.vala            |  6 +++---
 src/preferences-dialog.vala | 30 +++++++++++++++---------------
 src/scoreboard.vala         |  6 +++---
 5 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/controls.vala b/src/controls.vala
index 584c9ff..f95d210 100644
--- a/src/controls.vala
+++ b/src/controls.vala
@@ -22,7 +22,7 @@ using Gtk;
 [GtkTemplate (ui = "/org/gnome/Nibbles/ui/controls.ui")]
 private class Controls : Box
 {
-    [GtkChild] private Box grids_box;
+    [GtkChild] private unowned Box grids_box;
     private Gee.LinkedList<ControlsGrid> grids = new Gee.LinkedList<ControlsGrid> ();
 
     private Gdk.Pixbuf arrow_pixbuf;
@@ -100,15 +100,15 @@ private class Controls : Box
 [GtkTemplate (ui = "/org/gnome/Nibbles/ui/controls-grid.ui")]
 private class ControlsGrid : Button
 {
-    [GtkChild] private Label name_label;
-    [GtkChild] private Image arrow_up;
-    [GtkChild] private Image arrow_down;
-    [GtkChild] private Image arrow_left;
-    [GtkChild] private Image arrow_right;
-    [GtkChild] private Label move_up_label;
-    [GtkChild] private Label move_down_label;
-    [GtkChild] private Label move_left_label;
-    [GtkChild] private Label move_right_label;
+    [GtkChild] private unowned Label name_label;
+    [GtkChild] private unowned Image arrow_up;
+    [GtkChild] private unowned Image arrow_down;
+    [GtkChild] private unowned Image arrow_left;
+    [GtkChild] private unowned Image arrow_right;
+    [GtkChild] private unowned Label move_up_label;
+    [GtkChild] private unowned Label move_down_label;
+    [GtkChild] private unowned Label move_left_label;
+    [GtkChild] private unowned Label move_right_label;
 
     internal WormProperties worm_props;
     internal ulong external_handler;
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 6961326..6bfb74a 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -40,30 +40,30 @@ private class NibblesWindow : ApplicationWindow
     private int window_height;
 
     /* Main widgets */
-    [GtkChild] private Stack main_stack;
-    [GtkChild] private Overlay overlay;
+    [GtkChild] private unowned Stack main_stack;
+    [GtkChild] private unowned Overlay overlay;
 
     /* HeaderBar */
-    [GtkChild] private HeaderBar headerbar;
-    [GtkChild] private MenuButton hamburger_menu;
-    [GtkChild] private Button new_game_button;
-    [GtkChild] private Button pause_button;
+    [GtkChild] private unowned HeaderBar headerbar;
+    [GtkChild] private unowned MenuButton hamburger_menu;
+    [GtkChild] private unowned Button new_game_button;
+    [GtkChild] private unowned Button pause_button;
 
     /* Pre-game screen widgets */
-    [GtkChild] private Players players;
-    [GtkChild] private Speed speed;
-    [GtkChild] private Controls controls;
+    [GtkChild] private unowned Players players;
+    [GtkChild] private unowned Speed speed;
+    [GtkChild] private unowned Controls controls;
 
     /* Statusbar widgets */
-    [GtkChild] private Stack statusbar_stack;
-    [GtkChild] private Label countdown;
-    [GtkChild] private Scoreboard scoreboard;
+    [GtkChild] private unowned Stack statusbar_stack;
+    [GtkChild] private unowned Label countdown;
+    [GtkChild] private unowned Scoreboard scoreboard;
     private Gdk.Pixbuf scoreboard_life;
 
     /* Rendering of the game */
     private NibblesView? view;
 
-    [GtkChild] private Box game_box;
+    [GtkChild] private unowned Box game_box;
     private Games.GridFrame frame;
 
     /* Game being played */
diff --git a/src/players.vala b/src/players.vala
index 9198412..4bde18e 100644
--- a/src/players.vala
+++ b/src/players.vala
@@ -21,9 +21,9 @@ using Gtk;
 [GtkTemplate (ui = "/org/gnome/Nibbles/ui/players.ui")]
 private class Players : Box
 {
-    [GtkChild] private ToggleButton worms4;
-    [GtkChild] private ToggleButton worms5;
-    [GtkChild] private ToggleButton worms6;
+    [GtkChild] private unowned ToggleButton worms4;
+    [GtkChild] private unowned ToggleButton worms5;
+    [GtkChild] private unowned ToggleButton worms6;
 
     private SimpleAction nibbles_number_action;
     private SimpleAction players_number_action;
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 216a1e2..2d3a7bf 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -24,21 +24,21 @@ private class PreferencesDialog : Window
     private GLib.Settings settings;
     private Gee.ArrayList<GLib.Settings> worm_settings;
 
-    [GtkChild] private Stack            stack;
-    [GtkChild] private Stack            headerbar_stack;
-    [GtkChild] private ComboBoxText     worm_combobox;
-    [GtkChild] private Gtk.ListStore    list_store_1;
-    [GtkChild] private Gtk.ListStore    list_store_2;
-    [GtkChild] private Gtk.ListStore    list_store_3;
-    [GtkChild] private Gtk.ListStore    list_store_4;
-    [GtkChild] private TreeView         tree_view_1;
-    [GtkChild] private TreeView         tree_view_2;
-    [GtkChild] private TreeView         tree_view_3;
-    [GtkChild] private TreeView         tree_view_4;
-    [GtkChild] private ComboBoxText     combo_box_1;
-    [GtkChild] private ComboBoxText     combo_box_2;
-    [GtkChild] private ComboBoxText     combo_box_3;
-    [GtkChild] private ComboBoxText     combo_box_4;
+    [GtkChild] private unowned Stack            stack;
+    [GtkChild] private unowned Stack            headerbar_stack;
+    [GtkChild] private unowned ComboBoxText     worm_combobox;
+    [GtkChild] private unowned Gtk.ListStore    list_store_1;
+    [GtkChild] private unowned Gtk.ListStore    list_store_2;
+    [GtkChild] private unowned Gtk.ListStore    list_store_3;
+    [GtkChild] private unowned Gtk.ListStore    list_store_4;
+    [GtkChild] private unowned TreeView         tree_view_1;
+    [GtkChild] private unowned TreeView         tree_view_2;
+    [GtkChild] private unowned TreeView         tree_view_3;
+    [GtkChild] private unowned TreeView         tree_view_4;
+    [GtkChild] private unowned ComboBoxText     combo_box_1;
+    [GtkChild] private unowned ComboBoxText     combo_box_2;
+    [GtkChild] private unowned ComboBoxText     combo_box_3;
+    [GtkChild] private unowned ComboBoxText     combo_box_4;
 
     private Gee.ArrayList<Gtk.ListStore>    list_stores;
     private Gee.ArrayList<TreeView>         tree_views;
diff --git a/src/scoreboard.vala b/src/scoreboard.vala
index a41aee1..aebc1cc 100644
--- a/src/scoreboard.vala
+++ b/src/scoreboard.vala
@@ -59,9 +59,9 @@ private class Scoreboard : Box
 [GtkTemplate (ui = "/org/gnome/Nibbles/ui/player-score-box.ui")]
 private class PlayerScoreBox : Box
 {
-    [GtkChild] private Label name_label;
-    [GtkChild] private Label score_label;
-    [GtkChild] private Grid lives_grid;
+    [GtkChild] private unowned Label name_label;
+    [GtkChild] private unowned Label score_label;
+    [GtkChild] private unowned Grid lives_grid;
 
     private Gee.LinkedList<Image> life_images = new Gee.LinkedList<Image> ();
 
-- 
GitLab

