Browse Source

Fix EndOn bug

gdouglas 11 years ago
parent
commit
effe180f03
4 changed files with 16 additions and 10 deletions
  1. 3 0
      gmsrc/doc/ChangeLog.txt
  2. 11 8
      gmsrc/src/gm/gmMachine.cpp
  3. 1 1
      gmsrc/src/gm/gmMachine.h
  4. 1 1
      gmsrc/src/gm/gmThread.cpp

+ 3 - 0
gmsrc/doc/ChangeLog.txt

@@ -410,3 +410,6 @@ o Add back ++,-- pre inc, dec operators (Experimental, code restored from v0.9)
 
 18/05/13
 o Reordered GC descruction sequence to avoid Write Barrier mis-fire.
+
+19/05/14
+o Fix EndOn bug reported by Korrion

+ 11 - 8
gmsrc/src/gm/gmMachine.cpp

@@ -1037,7 +1037,7 @@ void gmMachine::Sys_SwitchState(gmThread * a_thread, int a_to)
     {
       // remove and clean up the blocks.
       Sys_RemoveSignals(a_thread); // Prevent signals from accumulating
-      Sys_RemoveBlocks(a_thread);
+      Sys_RemoveBlocks(a_thread, false);
       m_blockedThreads.Remove(a_thread);
       break;
     } 
@@ -1748,20 +1748,23 @@ void gmMachine::ResetDefaultTypes()
 
 
 
-void gmMachine::Sys_RemoveBlocks(gmThread * a_thread)
+void gmMachine::Sys_RemoveBlocks(gmThread * a_thread, bool a_includeEndOnBlocks)
 {
   gmBlock * block = a_thread->Sys_GetBlocks(), * next;
   while(block)
   {
     next = block->m_nextBlock;
-    gmBlockList * list = block->m_list;
-    block->Remove();
-    if(list->m_blocks.IsEmpty())
+    if( !block->m_endOn || a_includeEndOnBlocks )
     {
-      list = (gmBlockList *) m_blocks.Remove(list);
-      Sys_Free(list);
+        gmBlockList * list = block->m_list;
+        block->Remove();
+        if(list->m_blocks.IsEmpty())
+        {
+          list = (gmBlockList *) m_blocks.Remove(list);
+          Sys_Free(list);
+        }
+        Sys_Free(block);
     }
-    Sys_Free(block);
     block = next;
   }
   a_thread->Sys_SetBlocks(NULL);

+ 1 - 1
gmsrc/src/gm/gmMachine.h

@@ -536,7 +536,7 @@ public:
   inline void * Sys_Alloc(int a_size);
   inline void Sys_Free(void * a_mem) { m_fixedSet.Free(a_mem); }
 
-  void Sys_RemoveBlocks(gmThread * a_thread);
+  void Sys_RemoveBlocks(gmThread * a_thread, bool a_includeEndOnBlocks);
   void Sys_RemoveSignals(gmThread * a_thread);
 
   void Sys_SignalCreateThread(gmThread * a_thread);

+ 1 - 1
gmsrc/src/gm/gmThread.cpp

@@ -1020,7 +1020,7 @@ LabelException:
 
 void gmThread::Sys_Reset(int a_id)
 {
-  m_machine->Sys_RemoveBlocks(this);
+  m_machine->Sys_RemoveBlocks(this, true);
   m_machine->Sys_RemoveSignals(this);
 
   gmStackFrame * frame;