After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735495 - [PATCH] Permit to clear board when there's only earmarks.
[PATCH] Permit to clear board when there's only earmarks.
Status: RESOLVED FIXED
Product: gnome-sudoku
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-sudoku-maint
gnome-sudoku-maint
Depends on:
Blocks:
 
 
Reported: 2014-08-27 04:18 UTC by Arnaud B.
Modified: 2014-09-06 15:59 UTC
See Also:
GNOME target: ---
GNOME version: 3.13/3.14


Attachments
Permit to clear board when there's only earmarks. (1.37 KB, patch)
2014-08-27 04:18 UTC, Arnaud B.
reviewed Details | Review
Allow clearing the board when only earmarks are placed (5.69 KB, patch)
2014-09-05 21:07 UTC, Michael Catanzaro
none Details | Review
Allow clearing the board when only earmarks are placed (5.69 KB, patch)
2014-09-06 15:58 UTC, Michael Catanzaro
none Details | Review
Allow clearing the board when only earmarks are placed (5.69 KB, patch)
2014-09-06 15:59 UTC, Michael Catanzaro
committed Details | Review

Description Arnaud B. 2014-08-27 04:18:23 UTC
Created attachment 284575 [details] [review]
Permit to clear board when there's only earmarks.

Sometimes, you find a sudoku grid where you can’t place any number directly. In this case, you use earmarks. In this cases, you should be able to clear the board, and to save the game state… Here is a patch that permits it.
Comment 1 Parin Porecha 2014-08-29 21:49:42 UTC
Review of attachment 284575 [details] [review]:

Looks good.
Since it depends on 'Clear earmarks on reset' patch, I'll test this after it gets fixed.
Comment 2 Michael Catanzaro 2014-09-04 21:45:16 UTC
Review of attachment 284575 [details] [review]:

Looks correct. I'm not enthusiastic about the triple for look in is_empty. There's already a counter of how many cells are filled on the board; I think it'd be best to add another counter for earmarks, so that this becomes a simple comparison.
Comment 3 Arnaud B. 2014-09-05 00:42:12 UTC
Adding a (public??) counter for a thing used (locally) at only one place looks like a bad idea for my little mind…
Comment 4 Michael Catanzaro 2014-09-05 14:05:53 UTC
I think it can be private.
Comment 5 Arnaud B. 2014-09-05 18:03:27 UTC
Well, I don’t know what you have in mind, or it’s so hacky that I cannot sign it. Don’t hesitate.
Comment 6 Michael Catanzaro 2014-09-05 21:07:28 UTC
Created attachment 285525 [details] [review]
Allow clearing the board when only earmarks are placed

How about this approach?
Comment 7 Arnaud B. 2014-09-06 00:03:22 UTC
> How about this approach?

Yeah, why not.

> @@ -191,7 +191,7 @@ public class SudokuSaver : Object
>              {
>                  reader.read_element (k);
>                  return_val_if_fail (reader.is_value (), null);
> -                board.earmarks[row, col, (int) reader.get_int_value ()] = true;
> +                board.enable_earmark (row, col, (int) reader.get_int_value ());

You’ll need a `reader.get_int_value () + 1` here, or saving bugs.
Comment 8 Arnaud B. 2014-09-06 00:06:24 UTC
Ooops, it’s not there.

> @@ -96,7 +96,7 @@ private class NumberPicker : Gtk.Grid
>      public void set_earmarks (int row, int col)
>      {
>          for (var i = 0; i < board.max_val; i++)
> -            set_earmark (row, col, i, board.earmarks[row, col, i]);
> +            set_earmark (row, col, i, board.is_earmark_enabled(row, col, i));
>      }

Here I think, a `i + 1` (or a `var i = 1; i <= board.max_val`).
Comment 9 Michael Catanzaro 2014-09-06 15:58:52 UTC
Created attachment 285578 [details] [review]
Allow clearing the board when only earmarks are placed

Good catch, thanks! I think I've fixed that now.
Comment 10 Michael Catanzaro 2014-09-06 15:59:27 UTC
Created attachment 285579 [details] [review]
Allow clearing the board when only earmarks are placed

Er, I think I posted the old patch again :)
Comment 11 Michael Catanzaro 2014-09-06 15:59:43 UTC
Attachment 285579 [details] pushed as 560849f - Allow clearing the board when only earmarks are placed