1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-18 12:13:09 +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() void CrashCatcher::waitMonitor()
{ {
if (WaitForSingleObject(mSignalAppEvent, CrashCatcherTimeout) != WAIT_OBJECT_0) if (!waitMonitorNoThrow())
throw std::runtime_error("Waiting for monitor failed"); throw std::runtime_error("Waiting for monitor failed");
} }
bool CrashCatcher::waitMonitorNoThrow()
{
return WaitForSingleObject(mSignalAppEvent, CrashCatcherTimeout) == WAIT_OBJECT_0;
}
void CrashCatcher::signalMonitor() void CrashCatcher::signalMonitor()
{ {
SetEvent(mSignalMonitorEvent); SetEvent(mSignalMonitorEvent);
@ -236,16 +241,9 @@ namespace Crash
signalMonitor(); signalMonitor();
try // 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
// give monitor a chance to start dumping waitMonitorNoThrow();
// 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)
{
}
shmLock(); shmLock();
CrashSHM::Status monitorStatus = mShm->mMonitorStatus; CrashSHM::Status monitorStatus = mShm->mMonitorStatus;
@ -253,7 +251,6 @@ namespace Crash
if (monitorStatus == CrashSHM::Status::DumpedSuccessfully) if (monitorStatus == CrashSHM::Status::DumpedSuccessfully)
{ {
std::string message = "OpenMW has encountered a fatal error.\nCrash dump saved to '" std::string message = "OpenMW has encountered a fatal error.\nCrash dump saved to '"
+ Misc::StringUtils::u8StringToString(getCrashDumpPath(*mShm).u8string()) + Misc::StringUtils::u8StringToString(getCrashDumpPath(*mShm).u8string())
+ "'.\nPlease report this to https://gitlab.com/OpenMW/openmw/issues !"; + "'.\nPlease report this to https://gitlab.com/OpenMW/openmw/issues !";

View file

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

View file

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