1
0
forked from mirrors/0ad

Fix windows SEH hook when crashing in an std::thread

Follows 107d3d461f and other 'pthread->std::thread' diffs.

Windows uses Structured Exception Handling to allow reporting errors
(both C++ and hardware) nicely. This works by wrapping the code in a
__try __catch block.
The pthread wrapper did this automatically, but we now need to do it
explicitly for std::thread.

Tested by: Stan
Differential Revision: https://code.wildfiregames.com/D3261
This was SVN commit r24530.
This commit is contained in:
wraitii
2021-01-10 08:39:54 +00:00
parent f876db857a
commit 5ee8354e99
25 changed files with 141 additions and 58 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -231,7 +231,7 @@ bool ProfileStart(JSContext* cx, uint argc, JS::Value* vp)
name = StringFlyweight(str).get().c_str();
}
if (CProfileManager::IsInitialised() && ThreadUtil::IsMainThread())
if (CProfileManager::IsInitialised() && Threading::IsMainThread())
g_Profiler.StartScript(name);
g_Profiler2.RecordRegionEnter(name);
@@ -243,7 +243,7 @@ bool ProfileStart(JSContext* cx, uint argc, JS::Value* vp)
bool ProfileStop(JSContext* UNUSED(cx), uint argc, JS::Value* vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (CProfileManager::IsInitialised() && ThreadUtil::IsMainThread())
if (CProfileManager::IsInitialised() && Threading::IsMainThread())
g_Profiler.Stop();
g_Profiler2.RecordRegionLeave();
@@ -368,7 +368,7 @@ ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugN
m(new ScriptInterface_impl(nativeScopeName, context))
{
// Profiler stats table isn't thread-safe, so only enable this on the main thread
if (ThreadUtil::IsMainThread())
if (Threading::IsMainThread())
{
if (g_ScriptStatsTable)
g_ScriptStatsTable->Add(this, debugName);
@@ -381,7 +381,7 @@ ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugN
ScriptInterface::~ScriptInterface()
{
if (ThreadUtil::IsMainThread())
if (Threading::IsMainThread())
{
if (g_ScriptStatsTable)
g_ScriptStatsTable->Remove(this);