X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/072df0b3af8232b789f57491bd4404cc15b2954a..303313165165302d5f95b234a79c83413ec9c8c8:/src/common/appcmn.cpp

diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp
index e22ebf4a33..25bda2572b 100644
--- a/src/common/appcmn.cpp
+++ b/src/common/appcmn.cpp
@@ -548,6 +548,24 @@ void ShowAssertDialog(const wxChar *szFile,
         wxStrcat(szBuf, wxT("."));
     }
 
+#if wxUSE_THREADS
+    // if we are not in the main thread,
+    // output the assert directly and trap since dialogs cannot be displayed
+    if (!wxThread::IsMain()) {
+        wxStrcat(szBuf, wxT(" [in child thread]"));
+#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
+        wxStrcat(szBuf, wxT("\r\n"));
+        OutputDebugString(szBuf);
+#else
+        // send to stderr
+        wxFprintf(stderr, wxT("%s\n"), szBuf);
+        fflush(stderr);
+#endif
+        // He-e-e-e-elp!! we're asserting in a child thread
+        wxTrap();
+    }
+#endif // wxUSE_THREADS
+
     if ( !s_bNoAsserts )
     {
         // send it to the normal log destination