[gbrainy] Do not re-init objects on preview



commit 6c29c1a17a2021ab19d42b6840383e785c893cfe
Author: Jordi Mas <jmas softcatala org>
Date:   Thu Apr 1 21:08:20 2010 +0200

    Do not re-init objects on preview

 src/Clients/Classical/Dialogs/CustomGameDialog.cs |   10 ++++++++--
 src/Core/Main/Game.cs                             |    9 +++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/CustomGameDialog.cs b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
index fa52416..05adeda 100644
--- a/src/Clients/Classical/Dialogs/CustomGameDialog.cs
+++ b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
@@ -118,8 +118,14 @@ namespace gbrainy.Clients.Classical
 		    	}
 
 			Game game = games_store.GetValue (iter, COL_OBJECT) as Game;
-			game.IsPreviewMode = true;
-			game.Initialize ();
+
+			// We should not be using IsPreviewMode to know if Initialize has been called
+			if (game.IsPreviewMode == false) 
+			{
+				game.IsPreviewMode = true;
+				game.Initialize ();
+			}
+
 			question_label.Text = game.Question;
 			drawing_area.puzzle = game;
 			drawing_area.QueueDraw ();
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index 1aa607a..f7e7b36 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -277,6 +277,15 @@ namespace gbrainy.Core.Main
 			if (containers.Contains (container))
 				throw new InvalidOperationException ("Child already exists in container");
 
+			foreach (Toolkit.Container previous in containers)
+			{
+				if (previous.X == container.X && previous.Y == container.Y &&
+					 previous.Width == container.Width && previous.Height == container.Height)
+				{
+					throw new InvalidOperationException ("Child on the same area exists in container. Overlapping drawings.");
+				}
+			}
+
 			container.DrawRequest += delegate (object sender, EventArgs e)
 			{
 				OnDrawRequest ();



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