diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-06-27 22:12:14 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-06-28 17:36:42 +0200 |
commit | 64e8c2adbbe13cf082819229b8014ffb28911b76 (patch) | |
tree | 159f2fb52562d72c1671b744b6d0ab9554e0a5ec | |
parent | efab07a370c52e57c4a4adaed1ab90e232caaf0b (diff) |
Test SvpSalYieldMutex like DBG_TESTSOLARMUTEX
Introduce and use DBG_TESTSVPYIELDMUTEX.
Change-Id: I002fa8faf744d69ab00ceeddda4f56b46aec0b34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118015
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r-- | vcl/headless/svpinst.cxx | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 638052611360..b488d54d7527 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -62,6 +62,23 @@ SvpSalInstance* SvpSalInstance::s_pDefaultInstance = nullptr; +#ifndef NDEBUG +static bool g_CheckedMutex = false; + +#define DBG_TESTSVPYIELDMUTEX() \ +do { \ + if (!g_CheckedMutex) \ + { \ + assert(dynamic_cast<SvpSalYieldMutex*>(GetYieldMutex()) != nullptr \ + && "This SvpSalInstance function requires use of SvpSalYieldMutex"); \ + g_CheckedMutex = true; \ + } \ +} while(false) + +#else // NDEBUG +#define DBG_TESTSVPYIELDMUTEX() ((void)0) +#endif + #if !defined(ANDROID) && !defined(IOS) static void atfork_child() @@ -158,23 +175,11 @@ void SvpSalInstance::TriggerUserEventProcessing() Wakeup(); } -#ifndef NDEBUG -static bool g_CheckedMutex = false; -#endif - void SvpSalInstance::Wakeup(SvpRequest const request) { -#ifndef NDEBUG - if (!g_CheckedMutex) - { - assert(dynamic_cast<SvpSalYieldMutex*>(GetYieldMutex()) != nullptr - && "This SvpSalInstance function requires use of SvpSalYieldMutex"); - g_CheckedMutex = true; - } -#endif + DBG_TESTSVPYIELDMUTEX(); ImplSVData* pSVData = ImplGetSVData(); - if (pSVData->mpWakeCallback && pSVData->mpPollClosure) pSVData->mpWakeCallback(pSVData->mpPollClosure); @@ -309,6 +314,8 @@ std::shared_ptr<SalBitmap> SvpSalInstance::CreateSalBitmap() void SvpSalInstance::ProcessEvent( SalUserEvent aEvent ) { + DBG_TESTSVPYIELDMUTEX(); + aEvent.m_pFrame->CallCallback( aEvent.m_nEvent, aEvent.m_pData ); if( aEvent.m_nEvent == SalEvent::Resize ) { @@ -316,14 +323,7 @@ void SvpSalInstance::ProcessEvent( SalUserEvent aEvent ) const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>( aEvent.m_pFrame); pSvpFrame->PostPaint(); } -#ifndef NDEBUG - if (!g_CheckedMutex) - { - assert(dynamic_cast<SvpSalYieldMutex*>(GetYieldMutex()) != nullptr - && "This SvpSalInstance function requires use of SvpSalYieldMutex"); - g_CheckedMutex = true; - } -#endif + SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex())); pMutex->m_NonMainWaitingYieldCond.set(); } @@ -448,14 +448,7 @@ void SvpSalInstance::updateMainThread() bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) { -#ifndef NDEBUG - if (!g_CheckedMutex) - { - assert(dynamic_cast<SvpSalYieldMutex*>(GetYieldMutex()) != nullptr - && "This SvpSalInstance function requires use of SvpSalYieldMutex"); - g_CheckedMutex = true; - } -#endif + DBG_TESTSVPYIELDMUTEX(); // first, process current user events bool bEvent = DispatchUserEvents(bHandleAllCurrentEvents); |