Browse Source

Improve minimal example. Not all errors were logged before exit.

Greg 15 years ago
parent
commit
a7e508ec1e
2 changed files with 15 additions and 2 deletions
  1. 5 1
      gmsrc/doc/ChangeLog.txt
  2. 10 1
      gmsrc/src/examples/Minimal/main.cpp

+ 5 - 1
gmsrc/doc/ChangeLog.txt

@@ -351,10 +351,14 @@ o Add some more gmVariable accessors (similar to gm_ex)
 o Remove orphaned code in gmBlock dated 25/10/04 "Changed behaviour of Block() to yeild if blocked on 'null'."
 o Changed block on null behavior to cause script thread exception.
 o Fix signal behavior so multiple signals cannot accumulate on a blocked thread. Thanks DrEvil.
-o Changing gm version format from vMajor.Minor.BetaLetter to vMajor.Minor.Build. Probably won't change coded version to store past Minor unless process is automated.
+o Changing gm version format from vMajor.Minor.BetaLetter to vMajor.Minor.Build. Probably won't change coded version to store past Minor unless process is automated. Probably won't use 4 components as each can be multi digit.
 
 04/02/10
 o Changed new to GM_NEW in gmCodeGen.cpp for consistency.  Thanks Sunray.
 
 15/03/10
 o Fix GC auto calibration. Thanks DrEvil.
+
+27/05/10
+o Improved Minimal example.  Not all errors were logged. Also enabled debug mode. Thanks xaxa.
+

+ 10 - 1
gmsrc/src/examples/Minimal/main.cpp

@@ -29,6 +29,8 @@ int main(int argc, char* argv[])
   char script[MAX_SCRIPT_SIZE];
   fgets(script, MAX_SCRIPT_SIZE-1, stdin);
   
+  machine->SetDebugMode(true); // Enable debug mode so errors are readable
+  
   // Compile the script, but don't run it for now
   int errors = machine->ExecuteString(script, NULL, false, NULL);
   // Dump compile time errors to output
@@ -49,8 +51,10 @@ int main(int argc, char* argv[])
     int lastTime = timeGetTime();
     
     // Keep executing script while threads persist
-    while(machine->Execute(deltaTime))
+    for(;;)
     {
+      int threadCount = machine->Execute(deltaTime);
+      
       // Update delta time
       int curTime = timeGetTime();
       deltaTime = curTime - lastTime;
@@ -64,6 +68,11 @@ int main(int argc, char* argv[])
         fprintf(stderr, "%s"GM_NL, message);
       }
       machine->GetLog().Reset();
+      
+      if( !threadCount ) // Exit here when necessary, to allow error logs to print
+      {
+        break;
+      }
     }
   }