Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gnome-sudoku for openSUSE:Factory checked in at 2024-06-10 17:38:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gnome-sudoku (Old) and /work/SRC/openSUSE:Factory/.gnome-sudoku.new.19518 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "gnome-sudoku" Mon Jun 10 17:38:09 2024 rev:53 rq:1179669 version:46.2 Changes: -------- --- /work/SRC/openSUSE:Factory/gnome-sudoku/gnome-sudoku.changes 2024-05-06 17:56:39.838538184 +0200 +++ /work/SRC/openSUSE:Factory/.gnome-sudoku.new.19518/gnome-sudoku.changes 2024-06-10 17:38:28.300813935 +0200 @@ -1,0 +2,7 @@ +Mon Jun 10 06:49:48 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org> + +- Update to version 46.2: + + Fix memory leaks. + + Fix print button not displaying. + +------------------------------------------------------------------- Old: ---- gnome-sudoku-46.1.obscpio New: ---- gnome-sudoku-46.2.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gnome-sudoku.spec ++++++ --- /var/tmp/diff_new_pack.erBo06/_old 2024-06-10 17:38:30.080879784 +0200 +++ /var/tmp/diff_new_pack.erBo06/_new 2024-06-10 17:38:30.084879931 +0200 @@ -17,7 +17,7 @@ Name: gnome-sudoku -Version: 46.1 +Version: 46.2 Release: 0 Summary: Sudoku Game for GNOME License: GPL-3.0-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.erBo06/_old 2024-06-10 17:38:30.116881116 +0200 +++ /var/tmp/diff_new_pack.erBo06/_new 2024-06-10 17:38:30.120881263 +0200 @@ -3,7 +3,7 @@ <service name="obs_scm" mode="manual"> <param name="scm">git</param> <param name="url">https://gitlab.gnome.org/GNOME/gnome-sudoku.git</param> - <param name="revision">46.1</param> + <param name="revision">46.2</param> <param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param> <param name="versionrewrite-pattern">v?(.*)\+0</param> <param name="versionrewrite-replacement">\1</param> ++++++ gnome-sudoku-46.1.obscpio -> gnome-sudoku-46.2.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/NEWS new/gnome-sudoku-46.2/NEWS --- old/gnome-sudoku-46.1/NEWS 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/NEWS 2024-06-09 18:03:36.000000000 +0200 @@ -1,3 +1,9 @@ +46.2 - June 9, 2024 +========================== + +- Fix memory leaks +- Fix print button not displaying + 46.1 - May 5, 2024 ========================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/data/org.gnome.Sudoku.appdata.xml.in new/gnome-sudoku-46.2/data/org.gnome.Sudoku.appdata.xml.in --- old/gnome-sudoku-46.1/data/org.gnome.Sudoku.appdata.xml.in 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/data/org.gnome.Sudoku.appdata.xml.in 2024-06-09 18:03:36.000000000 +0200 @@ -25,10 +25,14 @@ </p> </description> <screenshots> - <screenshot height="577" width="748" type="default"> + <screenshot type="default"> <image>https://gitlab.gnome.org/GNOME/gnome-sudoku/-/raw/master/data/screenshot.png</image> <caption>A GNOME sudoku game preview</caption> </screenshot> + <screenshot environment="gnome:dark"> + <image>https://gitlab.gnome.org/GNOME/gnome-sudoku/-/raw/master/data/screenshot.png</image> + <caption>A GNOME sudoku game preview in dark mode</caption> + </screenshot> </screenshots> <launchable type="desktop-id">org.gnome.Sudoku.desktop</launchable> <url type="homepage">https://wiki.gnome.org/Apps/Sudoku</url> @@ -43,6 +47,7 @@ <id>gnome-sudoku.desktop</id> </provides> <releases> + <release version="46.2" date="2024-06-09"/> <release version="46.1" date="2024-05-05"/> <release version="46.0" date="2024-03-15"/> <release version="46~rc" date="2024-02-29"/> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/data/print-dialog.ui new/gnome-sudoku-46.2/data/print-dialog.ui --- old/gnome-sudoku-46.1/data/print-dialog.ui 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/data/print-dialog.ui 2024-06-09 18:03:36.000000000 +0200 @@ -3,12 +3,12 @@ <requires lib="gtk+" version="3.12"/> <template class="PrintDialog" parent="AdwWindow"> <property name="title" translatable="yes">Print Multiple Puzzles</property> - <property name="resizable">False</property> + <property name="resizable">True</property> <property name="width-request">460</property> <property name="modal">True</property> <property name="default-widget">print_button</property> <property name="focus-widget">print_button</property> - <child> + <property name="content"> <object class="AdwToolbarView"> <child type="top"> <object class="AdwHeaderBar"/> @@ -64,27 +64,25 @@ </property> </object> </child> + <child> + <object class="GtkButton" id="print_button"> + <property name="margin-top">12</property> + <property name="halign">end</property> + <property name="label" translatable="yes">_Print</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <style> + <class name="suggested-action"/> + </style> + </object> + </child> </object> </child> </object> </child> </object> </property> - <child type="bottom"> - <object class="GtkActionBar"> - <child type="end"> - <object class="GtkButton" id="print_button"> - <property name="label" translatable="yes">_Print</property> - <property name="receives-default">False</property> - <property name="use-underline">True</property> - <style> - <class name="suggested-action"/> - </style> - </object> - </child> - </object> - </child> </object> - </child> + </property> </template> </interface> Binary files old/gnome-sudoku-46.1/data/screenshot-dark.png and new/gnome-sudoku-46.2/data/screenshot-dark.png differ Binary files old/gnome-sudoku-46.1/data/screenshot.png and new/gnome-sudoku-46.2/data/screenshot.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/lib/sudoku-game.vala new/gnome-sudoku-46.2/lib/sudoku-game.vala --- old/gnome-sudoku-46.1/lib/sudoku-game.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/lib/sudoku-game.vala 2024-06-09 18:03:36.000000000 +0200 @@ -50,7 +50,6 @@ public bool[] earmarks; } - private Gee.List<UndoItem?> undostack; private Gee.List<UndoItem?> redostack; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/meson.build new/gnome-sudoku-46.2/meson.build --- old/gnome-sudoku-46.1/meson.build 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/meson.build 2024-06-09 18:03:36.000000000 +0200 @@ -4,7 +4,7 @@ ], license: 'GPL3+', meson_version: '>= 0.59', - version: '46.1' + version: '46.2' ) application_id = 'org.gnome.Sudoku' add_project_arguments([ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/aspect-frame.vala new/gnome-sudoku-46.2/src/aspect-frame.vala --- old/gnome-sudoku-46.1/src/aspect-frame.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/aspect-frame.vala 2024-06-09 18:03:36.000000000 +0200 @@ -75,10 +75,16 @@ } public SudokuFrame (Widget? child) - { - this.child = child; + { + this.child = child; - this.set_css_name ("aspectframe"); - this.set_accessible_role (AccessibleRole.GROUP); - } + this.set_css_name ("aspectframe"); + this.set_accessible_role (AccessibleRole.GROUP); + } + + public override void dispose () + { + child.unparent (); + base.dispose (); + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/gnome-sudoku.vala new/gnome-sudoku-46.2/src/gnome-sudoku.vala --- old/gnome-sudoku-46.1/src/gnome-sudoku.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/gnome-sudoku.vala 2024-06-09 18:03:36.000000000 +0200 @@ -31,10 +31,11 @@ { private GLib.Settings settings; - private SudokuWindow? window = null; + private SudokuWindow window; + private SudokuGame? game = null; - private SudokuView? view + private SudokuView view { get { return window.view; } } @@ -208,6 +209,9 @@ if (game != null) { + //Source timer holds a game ref + game.stop_clock (); + if (!game.is_empty () && !game.board.complete) saver.save_game (game); @@ -316,9 +320,7 @@ game.stop_clock (); - for (var i = 0; i < game.board.rows; i++) - for (var j = 0; j < game.board.cols; j++) - view.can_focus = false; + view.can_focus = false; saver.add_game_to_finished (game, true); @@ -363,14 +365,6 @@ if (current_game_mode == GameMode.PLAY) board.solve (); - if (game != null) - { - game.paused_changed.disconnect (paused_changed_cb); - game.board.cell_changed.disconnect (cell_modified_cb); - game.board.earmark_changed.disconnect (cell_modified_cb); - game.board.completed.disconnect (board_completed_cb); - } - game = new SudokuGame (board); game.mode = current_game_mode; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/number-picker.vala new/gnome-sudoku-46.2/src/number-picker.vala --- old/gnome-sudoku-46.1/src/number-picker.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/number-picker.vala 2024-06-09 18:03:36.000000000 +0200 @@ -25,22 +25,25 @@ { private SudokuBoard board; - public signal void number_picked (int number); - public signal void earmark_state_changed (int number, bool active); + public signal void value_picked (int val); + public signal void earmark_state_changed (int num, bool active); private Button clear_button; - - private int earmarks_active; + private Button[] value_buttons; + private ToggleButton[] earmark_buttons; public bool is_earmark_picker { get; private set; } public NumberPicker (SudokuGame game, bool for_earmarks = false) { board = game.board; - earmarks_active = 0; - is_earmark_picker = for_earmarks; + if (is_earmark_picker) + earmark_buttons = new ToggleButton [board.block_cols * board.block_rows]; + else + value_buttons = new Button [board.block_cols * board.block_rows]; + for (var col = 0; col < board.block_cols; col++) { for (var row = 0; row < board.block_rows; row++) @@ -60,21 +63,29 @@ button.set_child (label); label.show (); + //workaround to avoid lambda capture and memory leak + button.set_data<int> ("number-contained", n); + if (!for_earmarks) - button.clicked.connect (() => { - number_picked (n); + { + value_buttons[n - 1] = button; + button.clicked.connect ((this_button) => { + value_picked (this_button.get_data<int> ("number-contained")); }); + } else { - var toggle_button = (ToggleButton) button; - toggle_button.toggled.connect (() => { - var toggle_active = toggle_button.get_active (); - earmark_state_changed (n, toggle_active); + earmark_buttons[n - 1] = (ToggleButton) button; + earmark_buttons[n - 1].toggled.connect ((this_button) => { + int number_contained = this_button.get_data<int> ("number-contained"); + var toggle_active = this_button.get_active (); + earmark_state_changed (number_contained, toggle_active); }); } + if (n == 5) - button.realize.connect (() => { - button.grab_focus (); + button.realize.connect ((this_button) => { + this_button.grab_focus (); }); button.show (); } @@ -89,18 +100,13 @@ clear_button.set_child (label); label.show (); - clear_button.clicked.connect (() => { - number_picked (0); + clear_button.clicked.connect ((this_button) => { + value_picked (0); earmark_state_changed (0, false); - if (for_earmarks) - { - for (var i = 0; i <= 8; i++) - { - var button = get_button_for (i); - button.set_active (false); - } - } + if (is_earmark_picker) + for (var i = 0; i < 9; i++) + earmark_buttons[i].set_active (false); }); this.valign = Align.CENTER; @@ -130,22 +136,25 @@ clear_button.sensitive = false; } - public void set_earmarks (int row, int col) + public void set_earmark_buttons (int row, int col) requires (is_earmark_picker) { - for (var i = 0; i < board.max_val; i++) - set_earmark (row, col, i, board.is_earmark_enabled (row, col, i + 1)); + for (var i = 1; i <= board.max_val; i++) + set_earmark_button (i, board.is_earmark_enabled (row, col, i)); } - public void set_earmark (int row, int col, int index, bool state) + public void set_earmark_button (int num, bool state) requires (is_earmark_picker) { - get_button_for (index).set_active (state); + earmark_buttons[num - 1].set_active (state); } - private ToggleButton get_button_for (int number) + public override void dispose () { - return (ToggleButton) this.get_child_at (number % board.block_cols, - (board.block_rows - 1) - (number / board.block_rows)); + clear_button.unparent (); + foreach (var button in earmark_buttons) + button.unparent (); + foreach (var button in value_buttons) + button.unparent (); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/sudoku-cell.vala new/gnome-sudoku-46.2/src/sudoku-cell.vala --- old/gnome-sudoku-46.1/src/sudoku-cell.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/sudoku-cell.vala 2024-06-09 18:03:36.000000000 +0200 @@ -29,31 +29,98 @@ private int col; private SudokuGame game; public signal void will_open_popover (); + private unowned SudokuView view; - /* Gesture Controllers */ private GestureClick button_controller = new GestureClick (); private GestureLongPress long_press_controller = new GestureLongPress (); - private EventControllerKey key_controller = new EventControllerKey (); - private Popover _popover = null; - public Popover popover - { - get { - if (_popover == null) - { - _popover = new Popover (); - _popover.autohide = false; - } - return _popover; - } - } + //Only initialized when the cell is not fixed + private bool control_key_pressed; + private Popover popover; + private EventControllerKey key_controller; + private NumberPicker earmark_picker; + private NumberPicker value_picker; // The label can also be set to X if the label is invalid. // If this happens, the value **must not** be changed, only the label. private Label value_label = new Label ("") { visible = false }; - private Label[] earmark_labels = new Label[8]; + private Label[] earmark_labels = new Label[9]; + + public SudokuCell (int row, int col, SudokuGame game, SudokuView view) + { + this.set_accessible_role (AccessibleRole.BUTTON); + + this.row = row; + this.col = col; + this.game = game; + this.view = view; + + if (value != 0) + { + value_label.set_label (this.value.to_string ()); + value_label.set_visible (true); + } + + focusable = true; + can_focus = true; + + this.set_fixed_css (true); + + this.notify["has-focus"].connect (focus_changed_cb); + this.button_controller.set_button (0 /* all buttons */); + + this.add_controller (this.button_controller); + this.add_controller (this.long_press_controller); + + this.long_press_controller.pressed.connect (long_press_cb); + this.button_controller.released.connect (button_released_cb); + + value_label.set_parent (this); + + int num = 0; + for (int row_tmp = 0; row_tmp < game.board.block_rows; row_tmp++) + { + for (int col_tmp = 0; col_tmp < game.board.block_cols; col_tmp++) + { + num++; + + earmark_labels[num - 1] = new Label (num.to_string ()) { + visible = false + }; + earmark_labels[num - 1].set_parent (this); + earmark_labels[num - 1].add_css_class ("earmark"); + } + } + + if (!is_fixed) + { + key_controller = new EventControllerKey (); + add_controller (this.key_controller); + key_controller.key_pressed.connect (key_pressed_cb); + key_controller.key_released.connect (key_released_cb); + + popover = new Popover (); + popover.set_autohide (false); + popover.set_parent (this); + var popover_controller = new EventControllerKey (); + popover_controller.key_pressed.connect (key_pressed_cb); + popover_controller.key_released.connect (key_released_cb); + (popover as Widget)?.add_controller (popover_controller); + + value_picker = new NumberPicker (game, false); + value_picker.value_picked.connect (value_picked_cb); + + earmark_picker = new NumberPicker (game, true); + earmark_picker.earmark_state_changed.connect (earmark_picked_cb); + } + } + + static construct + { + set_css_name ("sudokucell"); + } public int value { @@ -165,74 +232,6 @@ earmark.remove_css_class ("highlight-label"); } - private bool control_key_pressed; - - public SudokuCell (int row, int col, ref SudokuGame game) - { - this.set_accessible_role (AccessibleRole.BUTTON); - - this.row = row; - this.col = col; - this.game = game; - - if (value != 0) - { - value_label.set_label (this.value.to_string ()); - value_label.set_visible (true); - } - - focusable = true; - can_focus = true; - - this.set_fixed_css (true); - - this.button_controller.set_button (0 /* all buttons */); - - this.add_controller (this.button_controller); - this.add_controller (this.long_press_controller); - this.add_controller (this.key_controller); - - this.long_press_controller.pressed.connect (long_press_cb); - this.button_controller.released.connect (button_released_cb); - this.key_controller.key_pressed.connect (key_pressed_cb); - this.key_controller.key_released.connect (key_released_cb); - - value_label.set_parent (this); - - int num = 0; - for (int row_tmp = 0; row_tmp < game.board.block_rows; row_tmp++) - { - for (int col_tmp = 0; col_tmp < game.board.block_cols; col_tmp++) - { - num++; - - earmark_labels[num - 1] = new Label (num.to_string ()) { - visible = false - }; - earmark_labels[num - 1].set_parent (this); - earmark_labels[num - 1].add_css_class ("earmark"); - } - } - - popover.set_parent (this); - var popover_controller = new EventControllerKey (); - popover_controller.key_pressed.connect (key_pressed_cb); - popover_controller.key_released.connect (key_released_cb); - (popover as Widget)?.add_controller (popover_controller); - popover.closed.connect (() => { - if (popover.visible) - { - popover.set_child (null); - this.grab_focus (); - } - }); - - } - - static construct { - set_css_name ("sudokucell"); - } - public void update_value () { if (value != 0) @@ -267,7 +266,7 @@ uint keycode, ModifierType state) { - if (is_fixed || game.paused) + if (game.paused) return; if (keyval == Key.Control_L || keyval == Key.Control_R) @@ -287,7 +286,7 @@ if (number_picker != null && number_picker.is_earmark_picker) { - number_picker.set_earmark (row, col, key - 1, new_state); + number_picker.set_earmark_button (key, new_state); } else { @@ -319,7 +318,7 @@ keyval == Gdk.Key.Return || keyval == Gdk.Key.KP_Enter) { - show_number_picker (); + show_value_picker (); return; } @@ -357,7 +356,7 @@ show_earmark_picker (); } else - show_number_picker (); + show_value_picker (); } else if (gesture.get_current_button () == BUTTON_SECONDARY && game.mode == GameMode.PLAY && @@ -379,11 +378,51 @@ return; if (game.mode == GameMode.CREATE) - show_number_picker (); + show_value_picker (); else if (this.value == 0) show_earmark_picker (); } + void focus_changed_cb () + { + if (game.paused) + return; + + if (this.has_focus) + view.set_selected (row, col); + } + + private void value_picked_cb (int val) + { + if (val > 0) + popover.popdown (); + else + { + this.game.board.disable_all_earmarks (row, col); + value_picker.set_clear_button_visibility (false); + } + this.value = val; + } + + private void earmark_picked_cb (int num, bool state) + { + if (state) + { + if (!this.game.board.is_earmark_enabled (row, col, num)) + this.game.enable_earmark (row, col, num); + } + else + { + if (num == 0) + this.game.disable_all_earmarks (row, col); + + else if (this.game.board.is_earmark_enabled (row, col, num)) + this.game.disable_earmark (row, col, num); + } + + earmark_picker.set_clear_button_enabled (this.game.board.has_earmarks (row, col)); + } + private int get_key_number (uint keyval) { switch (keyval) @@ -458,68 +497,39 @@ private void show_earmark_picker () requires (this.value == 0) { - if (this.popover.visible) + if (popover.visible) { + bool is_earmark_picker = ((NumberPicker)popover.child).is_earmark_picker; dismiss_popover (); - if (((NumberPicker)popover.child).is_earmark_picker) + if (is_earmark_picker) return; } will_open_popover (); - var earmark_picker = new NumberPicker (game, true); earmark_picker.set_clear_button_visibility (true); - if (!this.game.board.has_earmarks (row, col)) + earmark_picker.set_earmark_buttons (row, col); + if (!game.board.has_earmarks (row, col)) earmark_picker.set_clear_button_enabled (false); - earmark_picker.earmark_state_changed.connect ((number, state) => { - if (state) - { - if (!this.game.board.is_earmark_enabled (row, col, number)) - this.game.enable_earmark (row, col, number); - } - else - { - if (number == 0) - this.game.disable_all_earmarks (row, col); - - else if (this.game.board.is_earmark_enabled (row, col, number)) - this.game.disable_earmark (row, col, number); - } - - earmark_picker.set_clear_button_enabled (this.game.board.has_earmarks (row, col)); - }); - earmark_picker.set_earmarks (row, col); popover.set_child (earmark_picker); - popover.popup (); } - private void show_number_picker () + private void show_value_picker () { - if (this.popover.visible) + if (popover.visible) { + bool is_earmark_picker = ((NumberPicker)popover.child).is_earmark_picker; dismiss_popover (); - if (!((NumberPicker)popover.child).is_earmark_picker) + if (!is_earmark_picker) return; } will_open_popover (); + value_picker.set_clear_button_visibility (value > 0 || game.board.has_earmarks (row, col)); - var number_picker = new NumberPicker (game); - number_picker.number_picked.connect ((o, number) => { - if (number > 0) - popover.popdown (); - else - { - this.game.board.disable_all_earmarks (row, col); - number_picker.set_clear_button_visibility (false); - } - value = number; - }); - number_picker.set_clear_button_visibility (value > 0 || game.board.has_earmarks (row, col)); - popover.set_child (number_picker); - + popover.set_child (value_picker); popover.popup (); } @@ -581,23 +591,16 @@ earmark_labels[num-1].remove_css_class ("error"); } - public override void dispose () - { - base.dispose (); - - this.value_label.unparent (); - } - public override void size_allocate (int width, int height, int baseline) { - this.popover.present (); + this.popover?.present (); int value_width, value_height; value_width = value_height = int.min (width, height); - set_font_size (ref value_label, height / size_ratio); + set_font_size (value_label, height / size_ratio); Gsk.Transform center = new Gsk.Transform ().translate (Graphene.Point ().init ( (width - value_width) / 2, @@ -616,7 +619,7 @@ { num++; - set_font_size (ref earmark_labels[num - 1], height / size_ratio / 2); + set_font_size (earmark_labels[num - 1], height / size_ratio / 2); Gsk.Transform earmark_position = new Gsk.Transform ().translate (Graphene.Point ().init ( col_tmp * earmark_width, @@ -628,7 +631,7 @@ } } - private void set_font_size (ref Label label, int font_size) + private void set_font_size (Label label, int font_size) { var attr_list = label.get_attributes (); if (attr_list == null) @@ -643,8 +646,19 @@ public void dismiss_popover () { - if (_popover != null) - _popover.popdown (); + if (popover != null) + { + popover.popdown (); + popover.child = null; + } } -} + public override void dispose () + { + this.value_label.unparent (); + foreach (Label earmark in earmark_labels) + earmark.unparent (); + popover?.unparent (); + base.dispose (); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/sudoku-view.vala new/gnome-sudoku-46.2/src/sudoku-view.vala --- old/gnome-sudoku-46.1/src/sudoku-view.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/sudoku-view.vala 2024-06-09 18:03:36.000000000 +0200 @@ -25,24 +25,17 @@ public class SudokuView : Adw.Bin { - private SudokuGame _game; - public SudokuGame game - { - get { return _game; } - private set { _game = value; } - } - + private SudokuGame game; private SudokuCell[,] cells; - private Label paused; - - private Overlay overlay; - private Grid grid; + SudokuFrame frame; + Label paused_label; public int selected_row { get; private set; default = 0; } public int selected_col { get; private set; default = 0; } + public signal void selection_changed (int old_row, int old_col, int new_row, int new_col); - private void set_selected (int cell_row, int cell_col) + public void set_selected (int cell_row, int cell_col) { if (selected_row == cell_row && selected_col == cell_col) return; @@ -64,8 +57,9 @@ public SudokuView (SudokuGame game, GLib.Settings settings) { - this.vexpand = true; + this.game = game; + this.vexpand = true; this.focusable = true; this.can_focus = true; @@ -77,20 +71,18 @@ this._show_extra_warnings = settings.get_boolean ("show-extra-warnings"); this._highlighter = settings.get_boolean ("highlighter"); - overlay = new Overlay (); - var frame = new SudokuFrame (overlay); + var overlay = new Overlay (); + frame = new SudokuFrame (overlay); this.set_child (frame); - this.paused = new Gtk.Label ("Paused"); - this.paused.add_css_class ("paused"); - - if (grid != null) - overlay.set_child (null); + paused_label = new Label ("Paused"); + paused_label.add_css_class ("paused"); + paused_label.set_visible (false); + overlay.add_overlay (paused_label); - this.game = game; this.game.paused_changed.connect(() => { // Set Font Size - var attr_list = this.paused.get_attributes (); + var attr_list = paused_label.get_attributes (); if (attr_list == null) attr_list = new Pango.AttrList (); @@ -98,8 +90,8 @@ Pango.AttrSize.new_absolute ((int) (this.get_width () * 0.125) * Pango.SCALE) ); - this.paused.set_attributes (attr_list); - paused.set_visible (this.game.paused); + paused_label.set_attributes (attr_list); + paused_label.set_visible (this.game.paused); if (this.game.paused) { @@ -115,7 +107,7 @@ has_selection = !this.game.paused; }); - grid = new Grid () { + var grid = new Grid () { row_spacing = 2, column_spacing = 2, column_homogeneous = true, @@ -124,6 +116,7 @@ hexpand = true }; grid.add_css_class ("board"); + overlay.set_child (grid); var blocks = new Grid[game.board.block_rows, game.board.block_cols]; for (var block_row = 0; block_row < game.board.block_rows; block_row++) @@ -147,26 +140,11 @@ { for (var col = 0; col < game.board.cols; col++) { - var cell = new SudokuCell (row, col, ref _game); - var cell_row = row; - var cell_col = col; - - cell.notify["has-focus"].connect (() => { - if (game.paused) - return; - - if (cell.has_focus) - this.set_selected (cell_row, cell_col); - }); - - cell.will_open_popover.connect (() => { - dismiss_popovers (); - }); - - cells[row, col] = cell; - cells[row, col].initialize_earmarks (show_possibilities); + var cell = new SudokuCell (row, col, game, this); + cell.initialize_earmarks (show_possibilities); blocks[row / game.board.block_rows, col / game.board.block_cols].attach (cell, col % game.board.block_cols, row % game.board.block_rows); + cells[row, col] = cell; } } @@ -175,11 +153,6 @@ this.selection_changed.connect (selection_changed_cb); update_warnings (); - overlay.add_overlay (paused); - overlay.set_child (grid); - grid.show (); - overlay.show (); - paused.set_visible (false); } static construct { @@ -457,5 +430,11 @@ for (var j = 0; j < game.board.cols; j++) cells[i,j].dismiss_popover (); } + + public override void dispose () + { + frame.unparent (); + base.dispose (); + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gnome-sudoku-46.1/src/sudoku-window.vala new/gnome-sudoku-46.2/src/sudoku-window.vala --- old/gnome-sudoku-46.1/src/sudoku-window.vala 2024-05-06 06:29:03.000000000 +0200 +++ new/gnome-sudoku-46.2/src/sudoku-window.vala 2024-06-09 18:03:36.000000000 +0200 @@ -58,11 +58,9 @@ private bool clock_in_headerbar; private GLib.Settings settings; - - public SudokuView? view { get; private set; } - private SudokuGame? game = null; + public SudokuView? view { get; private set; default = null;} private const int board_size = 140; private const int clock_in_headerbar_min_width = 450; @@ -183,8 +181,6 @@ public void start_game (SudokuGame game) { - if (this.game != null) - this.game.tick.disconnect (tick_cb); this.game = game; game.tick.connect (tick_cb); game.start_clock (); ++++++ gnome-sudoku.obsinfo ++++++ --- /var/tmp/diff_new_pack.erBo06/_old 2024-06-10 17:38:30.368890438 +0200 +++ /var/tmp/diff_new_pack.erBo06/_new 2024-06-10 17:38:30.372890586 +0200 @@ -1,5 +1,5 @@ name: gnome-sudoku -version: 46.1 -mtime: 1714969743 -commit: eacfbb5e59bb5e3e99e0c442792bf38b0b4809ad +version: 46.2 +mtime: 1717949016 +commit: f70b12b0f381faeaad4310dd1c7999047ca37631