[gnome-sudoku/gnome-3-16: 9/14] Verify that SudokuView object exists before calling its methods



commit 418bbc77270b6043631e7c8806c283f4b9bf06a4
Author: Andrei Ghincu <ghincuandrei gmail com>
Date:   Fri Nov 14 13:23:46 2014 +0200

    Verify that SudokuView object exists before calling its methods
    
    Before this, when changing options (highlighter and warnings) from the
    menu during the 'Select Difficulty' screen the following error messages
    were shown:
    ** (gnome-sudoku:11303): CRITICAL **: sudoku_view_set_highlighter: assertion 'self != NULL' failed
    and similar for the 'warnings' option:
    ** (gnome-sudoku:11303): CRITICAL **: sudoku_view_set_show_warnings: assertion 'self != NULL' failed
    (even though the option changes would be applied when the new game started).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740114

 src/gnome-sudoku.vala |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index a48d64c..8892ba1 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -128,13 +128,17 @@ public class Sudoku : Gtk.Application
 
         settings = new GLib.Settings ("org.gnome.sudoku");
         var action = settings.create_action ("show-warnings");
-        action.notify["state"].connect (() =>
-            view.show_warnings = settings.get_boolean ("show-warnings"));
+        action.notify["state"].connect (() => {
+            if (view != null)
+                view.show_warnings = settings.get_boolean ("show-warnings");
+        });
         add_action (action);
 
         var highlighter_action = settings.create_action ("highlighter");
-        highlighter_action.notify["state"].connect (() =>
-            view.highlighter = settings.get_boolean ("highlighter"));
+        highlighter_action.notify["state"].connect (() => {
+            if (view != null)
+                view.highlighter = settings.get_boolean ("highlighter");
+        });
         add_action (highlighter_action);
 
         set_accels_for_action ("app.new-game", {"<Primary>n"});


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