summaryrefslogtreecommitdiff
path: root/libreofficekit/source/gtk/lokdocview.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-10-18 21:37:15 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-10-22 11:55:53 +0200
commit28c187c8f91e09dbcc3b1037d5076a3b1f661391 (patch)
tree28fe3e44d4e631cc94cafc1da62b063c9bda1720 /libreofficekit/source/gtk/lokdocview.cxx
parent7c76f391296ef129e89c724bff26cc1bd3aefa27 (diff)
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>
Diffstat (limited to 'libreofficekit/source/gtk/lokdocview.cxx')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx29
1 files changed, 20 insertions, 9 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 5dddaa2d0e37..6d34f263733d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2457,6 +2457,25 @@ postCommandInThread (gpointer data)
}
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)
{
GTask* task = G_TASK(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";