浏览代码

Added main thread ID check in Log::HandleEndFrame().

Lasse Öörni 11 年之前
父节点
当前提交
636562bd23
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      Source/Engine/IO/Log.cpp

+ 12 - 0
Source/Engine/IO/Log.cpp

@@ -55,6 +55,7 @@ const char* logLevelPrefixes[] =
 };
 
 static Log* logInstance = 0;
+static bool threadErrorDisplayed = false;
 
 Log::Log(Context* context) :
     Object(context),
@@ -251,6 +252,17 @@ void Log::WriteRaw(const String& message, bool error)
 
 void Log::HandleEndFrame(StringHash eventType, VariantMap& eventData)
 {
+    // If the MainThreadID is not valid, processing this loop can potentially be endless
+    if (!Thread::IsMainThread())
+    {
+        if (!threadErrorDisplayed)
+        {
+            fprintf(stderr, "Thread::mainThreadID is not setup correctly! Threaded log handling disabled\n");
+            threadErrorDisplayed = true;
+        }
+        return;
+    }
+
     MutexLock lock(logMutex_);
     
     // Process messages accumulated from other threads (if any)