summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-03-20 23:05:22 +0100
committerJan Holesovsky <kendy@collabora.com>2017-03-20 23:08:51 +0100
commit8b446be53930bc847d45b0b6f60f9f47d39cd88c (patch)
tree51c28bebff5b4558af216614214fbb9b49cb7995 /desktop
parent260801511467854a4f9a5cdb3b0aed3661c26fe7 (diff)
lok: Fix crash in paintPartTile() when the current view was destroyed.
Change-Id: I59b71ee6815cbcfa4c8b5f68ae6dc9299856d49e
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 54c1bf2b2960..597a225f20b2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1631,11 +1631,27 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis,
<< nTilePosX << ", " << nTilePosY << ") to ["
<< nCanvasWidth << "x" << nCanvasHeight << "]px" );
- // Disable callbacks while we are painting.
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- const int nOrigViewId = doc_getView(pThis);
+ int nOrigViewId = doc_getView(pThis);
+
+ if (nOrigViewId < 0)
+ {
+ // tile painting always needs a SfxViewShell::Current(), but actually
+ // it does not really matter which one - all of them should paint the
+ // same thing.
+ int viewCount = doc_getViewsCount(pThis);
+ if (viewCount == 0)
+ return;
- if (nOrigViewId >= 0)
+ std::vector<int> viewIds(viewCount);
+ doc_getViewIds(pThis, viewIds.data(), viewCount);
+
+ nOrigViewId = viewIds[0];
+ doc_setView(pThis, nOrigViewId);
+ }
+
+ // Disable callbacks while we are painting.
+ if (nOrigViewId >= 0 && pDocument->mpCallbackFlushHandlers[nOrigViewId])
pDocument->mpCallbackFlushHandlers[nOrigViewId]->setPartTilePainting(true);
try
@@ -1686,7 +1702,7 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis,
// Nothing to do but restore the PartTilePainting flag.
}
- if (nOrigViewId >= 0)
+ if (nOrigViewId >= 0 && pDocument->mpCallbackFlushHandlers[nOrigViewId])
pDocument->mpCallbackFlushHandlers[nOrigViewId]->setPartTilePainting(false);
}