1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-07-01 18:11:34 +00:00

Some review stuff

This commit is contained in:
AnyOldName3 2025-06-09 14:13:50 +01:00
parent 9010a5bb32
commit 7347f4f4e3
3 changed files with 14 additions and 18 deletions

View file

@ -149,10 +149,15 @@ namespace Crash
void CrashCatcher::waitMonitor()
{
if (WaitForSingleObject(mSignalAppEvent, CrashCatcherTimeout) != WAIT_OBJECT_0)
if (!waitMonitorNoThrow())
throw std::runtime_error("Waiting for monitor failed");
}
bool CrashCatcher::waitMonitorNoThrow()
{
return WaitForSingleObject(mSignalAppEvent, CrashCatcherTimeout) == WAIT_OBJECT_0;
}
void CrashCatcher::signalMonitor()
{
SetEvent(mSignalMonitorEvent);
@ -236,16 +241,9 @@ namespace Crash
signalMonitor();
try
{
// give monitor a chance to start dumping
// do this in try/catch as dumping might take longer than the timeout and an exception will be thrown when
// we're resumed
waitMonitor();
}
catch (std::exception)
{
}
// give monitor a chance to start dumping
// as we're suspended, this might time out even if it's successful, so mMonitorStatus is the source of truth
waitMonitorNoThrow();
shmLock();
CrashSHM::Status monitorStatus = mShm->mMonitorStatus;
@ -253,7 +251,6 @@ namespace Crash
if (monitorStatus == CrashSHM::Status::DumpedSuccessfully)
{
std::string message = "OpenMW has encountered a fatal error.\nCrash dump saved to '"
+ Misc::StringUtils::u8StringToString(getCrashDumpPath(*mShm).u8string())
+ "'.\nPlease report this to https://gitlab.com/OpenMW/openmw/issues !";

View file

@ -66,6 +66,7 @@ namespace Crash
const std::filesystem::path& freezeDumpName);
void waitMonitor();
bool waitMonitorNoThrow();
void signalMonitor();

View file

@ -312,12 +312,10 @@ namespace Crash
failedDumping(ss.str());
return;
}
else
{
shmLock();
mShm->mMonitorStatus = CrashSHM::Status::DumpedSuccessfully;
shmUnlock();
}
shmLock();
mShm->mMonitorStatus = CrashSHM::Status::DumpedSuccessfully;
shmUnlock();
}
catch (const std::exception& e)
{