cid#1606773 Check of thread-shared field evades lock acquisition

Change-Id: Ia1d9d91f1ca76e5fcf311c51fc560a41e72338d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175376
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2024-10-18 21:37:15 +01:00
parent 7c76f39129
commit 28c187c8f9

View file

@ -2456,6 +2456,25 @@ postCommandInThread (gpointer data)
priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pLOEvent->m_pCommand, pLOEvent->m_pArguments, pLOEvent->m_bNotifyWhenFinished);
}
static void
paintTile(LOKDocViewPrivate& priv,
unsigned char* pBuffer,
const GdkRectangle& rTileRectangle,
gint nTileSizePixelsScaled,
LOEvent* pLOEvent,
gint nScaleFactor)
{
std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
setDocumentView(priv->m_pDocument, priv->m_nViewId);
priv->m_pDocument->pClass->paintTile(priv->m_pDocument,
pBuffer,
nTileSizePixelsScaled, nTileSizePixelsScaled,
rTileRectangle.x, rTileRectangle.y,
pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor),
pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor));
}
static void
paintTileInThread (gpointer data)
{
@ -2496,8 +2515,6 @@ paintTileInThread (gpointer data)
aTileRectangle.x = pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor) * pLOEvent->m_nPaintTileY;
aTileRectangle.y = pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor) * pLOEvent->m_nPaintTileX;
std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
setDocumentView(priv->m_pDocument, priv->m_nViewId);
std::stringstream ss;
GTimer* aTimer = g_timer_new();
gulong nElapsedMs;
@ -2507,13 +2524,7 @@ paintTileInThread (gpointer data)
<< pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor) << ", "
<< pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor) << ")";
priv->m_pDocument->pClass->paintTile(priv->m_pDocument,
pBuffer,
nTileSizePixelsScaled, nTileSizePixelsScaled,
aTileRectangle.x, aTileRectangle.y,
pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor),
pixelToTwip(nTileSizePixelsScaled, pLOEvent->m_fPaintTileZoom * nScaleFactor));
aGuard.unlock();
paintTile(priv, pBuffer, aTileRectangle, nTileSizePixelsScaled, pLOEvent, nScaleFactor);
g_timer_elapsed(aTimer, &nElapsedMs);
ss << " rendered in " << (nElapsedMs / 1000.) << " milliseconds";