sfx2: nullptr pViewShell was seen in SfxLokHelper::getView()
I'm not sure how to trigger this reliably, but Pranav got this: #0 0x00007fb2f471bbf0 in SfxLokHelper::getView(SfxViewShell*) (pViewShell=0x0) at sfx2/source/view/lokhelper.cxx:82 #1 0x00007fb2f75edf4f in doc_paintPartTile(LibreOfficeKitDocument*, unsigned char*, int, int, int, int, int, int, int) (pThis=0x7fb290253c40, pBuffer=0x281fbd0 "", nPart=0, nCanvasWidth=1024, nCanvasHeight=256, nTilePosX=0, nTilePosY=11520, nTileWidth=15360, nTileHeight=3840) at desktop/source/lib/init.cxx:1338 Given that SfxViewShell::Current() may indeed return nullptr (e.g. during shutdown), change SfxLokHelper::getView() to return -1 in that case, and adapt client code to handle that. Change-Id: Ia191c843c8a993f3d7157de432af57964c0a8f63 Reviewed-on: https://gerrit.libreoffice.org/28583 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
@@ -1365,7 +1365,10 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
|
|||||||
|
|
||||||
// Disable callbacks while we are painting.
|
// Disable callbacks while we are painting.
|
||||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
std::size_t nView = SfxLokHelper::getView();
|
int nView = SfxLokHelper::getView();
|
||||||
|
if (nView < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(true);
|
pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1438,7 +1441,10 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
|
|||||||
SolarMutexGuard aGuard;
|
SolarMutexGuard aGuard;
|
||||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
|
|
||||||
std::size_t nView = SfxLokHelper::getView();
|
int nView = SfxLokHelper::getView();
|
||||||
|
if (nView < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pThis, pCallback, pData));
|
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pThis, pCallback, pData));
|
||||||
|
|
||||||
if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
|
if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
|
||||||
@@ -1507,7 +1513,9 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
|
|||||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
|
|
||||||
std::vector<beans::PropertyValue> aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
|
std::vector<beans::PropertyValue> aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
|
||||||
std::size_t nView = SfxLokHelper::getView();
|
int nView = SfxLokHelper::getView();
|
||||||
|
if (nView < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// handle potential interaction
|
// handle potential interaction
|
||||||
if (gImpl && aCommand == ".uno:Save")
|
if (gImpl && aCommand == ".uno:Save")
|
||||||
@@ -1593,7 +1601,10 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
std::size_t nView = SfxLokHelper::getView();
|
int nView = SfxLokHelper::getView();
|
||||||
|
if (nView < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pLib->mpCallbackFlushHandlers[nView])
|
if (pLib->mpCallbackFlushHandlers[nView])
|
||||||
{
|
{
|
||||||
pLib->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr());
|
pLib->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr());
|
||||||
|
@@ -83,6 +83,10 @@ int SfxLokHelper::getView(SfxViewShell* pViewShell)
|
|||||||
{
|
{
|
||||||
if (!pViewShell)
|
if (!pViewShell)
|
||||||
pViewShell = SfxViewShell::Current();
|
pViewShell = SfxViewShell::Current();
|
||||||
|
// Still no valid view shell? Then no idea.
|
||||||
|
if (!pViewShell)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return pViewShell->GetViewShellId();
|
return pViewShell->GetViewShellId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user