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-21 10:51:58 +0000
commit89f5bb3cbbddd0b7b815ddd96f25500a9ff78e8b (patch)
tree3afc7398086973a3e2404259bfb81aeabdce674c /desktop
parentb6e62dc0dc2b284c825f1182a67bb2f9259a30ce (diff)
lok: Fix crash in paintPartTile() when the current view was destroyed.
Change-Id: I59b71ee6815cbcfa4c8b5f68ae6dc9299856d49e Reviewed-on: https://gerrit.libreoffice.org/35494 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
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 935bc45dadd5..0e73a272cce1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1824,11 +1824,27 @@ static 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
@@ -1879,7 +1895,7 @@ static 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);
}