attempt to fix macos jenkins hangs - part 3
oox::xls::WorkbookFragment::finalizeImport() calls
AquaSalInstance::DoYield() with bWait set to true. But
since unit tests generally have no expected user generated
events, we can end up blocking and waiting forever so
don't block and wait when running unit tests.
Change-Id: I14cfdb88f04b82f49e8c15e554e5c4b4053e77b3
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 412aacd..ce8c491 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -553,6 +553,23 @@ static bool isWakeupEvent( NSEvent *pEvent )
&& AquaSalInstance::YieldWakeupEvent == static_cast<int>([pEvent subtype]);
}
static bool isInCppunitTest()
{
static bool bInCppunitTest = false;
static bool bInCppunitTestInitialized = false;
if (!bInCppunitTestInitialized)
{
const auto appFileName = Application::GetAppFileName();
const auto slash = appFileName.lastIndexOf('/');
const auto baseName = (slash >= 0) ? OUString(appFileName.subView(slash + 1)) : appFileName;
bInCppunitTest = (baseName == "cppunittester");
bInCppunitTestInitialized = true;
}
return bInCppunitTest;
}
bool AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
{
// Related: tdf#152703 Eliminate potential blocking during live resize
@@ -630,8 +647,14 @@ bool AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
{
SolarMutexReleaser aReleaser;
// attempt to fix macos jenkins hangs - part 3
// oox::xls::WorkbookFragment::finalizeImport() calls
// AquaSalInstance::DoYield() with bWait set to true. But
// since unit tests generally have no expected user generated
// events, we can end up blocking and waiting forever so
// don't block and wait when running unit tests.
pEvent = [NSApp nextEventMatchingMask: NSEventMaskAny
untilDate: [NSDate distantFuture]
untilDate: isInCppunitTest() ? [NSDate distantPast] : [NSDate distantFuture]
inMode: NSDefaultRunLoopMode
dequeue: YES];
if( pEvent )