From 40be36ec2c6b1fb93b6ad1bee55be2c2232a849b Mon Sep 17 00:00:00 2001
From: Sam Hocevar <sam@hocevar.net>
Date: Mon, 26 Mar 2012 18:18:33 +0000
Subject: [PATCH] test: fix logic bugs in two tutorials.

---
 test/tutorial/tut02.cpp | 2 ++
 test/tutorial/tut03.cpp | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/tutorial/tut02.cpp b/test/tutorial/tut02.cpp
index c08d1604..8e4f2975 100644
--- a/test/tutorial/tut02.cpp
+++ b/test/tutorial/tut02.cpp
@@ -66,6 +66,8 @@ public:
         m_indices[9] = i16vec3(1, 0, 4);
         m_indices[10] = i16vec3(3, 2, 6);
         m_indices[11] = i16vec3(6, 7, 3);
+
+        m_ready = false;
     }
 
     virtual void TickGame(float deltams)
diff --git a/test/tutorial/tut03.cpp b/test/tutorial/tut03.cpp
index fa0d90e5..646fe94a 100644
--- a/test/tutorial/tut03.cpp
+++ b/test/tutorial/tut03.cpp
@@ -159,9 +159,12 @@ public:
 
     ~Fractal()
     {
-        /* Signal worker threads for completion. */
+        /* Signal worker threads for completion and wait for
+         * them to quit. */
         for (int i = 0; i < MAX_THREADS; i++)
             m_jobqueue.Push(-1);
+        for (int i = 0; i < MAX_THREADS; i++)
+            m_donequeue.Pop();
 
         Input::UntrackMouse(this);
 #if !defined __native_client__
@@ -337,6 +340,7 @@ public:
             that->DoWork(line);
             that->m_donequeue.Push(0);
         }
+        that->m_donequeue.Push(0);
         return NULL;
     };