[gnome-sudoku] Verify that SudokuView object exists before calling its methods



commit 5a8ef0a8d773539af72bc2477248596360600862
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 42eb064..1ff9cb3 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -133,13 +133,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]