[gnome-games] [lightsoff] Ensure level is never < 1 (causes infinite loop)



commit 5f92ad2fdb1081e42d0451580f87490653f0e481
Author: Tim Horton <hortont424 gmail com>
Date:   Wed Aug 5 23:28:14 2009 -0400

    [lightsoff] Ensure level is never < 1 (causes infinite loop)
    
    For some reason, it seems that if the machine (or gconfd, or something)
    isn't restarted after installing schemas, they don't take effect.
    
    This was causing us to successfully load a score of 0, locking up the
    load_level function.
    
    I believe that the libgames-support conf stuff has defaults in itself, so
    once we switch to that, that will also solve this problem. Still, there
    must be some form of solution to the GConf schema loading problem too...

 lightsoff/src/Board.js    |    7 +++++++
 lightsoff/src/Settings.js |    8 ++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/lightsoff/src/Board.js b/lightsoff/src/Board.js
index c654507..20aa694 100644
--- a/lightsoff/src/Board.js
+++ b/lightsoff/src/Board.js
@@ -170,6 +170,13 @@ BoardView = new GType({
 		{
 			loading_level = true;
 			
+			// We *must* not have level < 1, as the following assumes
+			// a nonzero, nonnegative number
+			if(level < 1)
+			{
+				level = 1;
+			}
+			
 			for(var x = 0; x < tiles; x++)
 				for(var y = 0; y < tiles; y++)
 					lights[x][y].set_state(0, 0);
diff --git a/lightsoff/src/Settings.js b/lightsoff/src/Settings.js
index ca87dec..30f580c 100644
--- a/lightsoff/src/Settings.js
+++ b/lightsoff/src/Settings.js
@@ -30,6 +30,14 @@ catch(e)
 	score = 1;
 }
 
+// If (machine isn't restarted?) after schema is installed, defaults
+// from GConf aren't set, so revert to defaults...
+if(score == 0)
+{
+	theme = themes[default_theme];
+	score = 1;
+}
+
 // Settings Event Handler
 
 SettingsWatcher = new GType({



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