sw: fix crash in SwXTextDocument::getDocumentSize()
gdb on the crashreport core dump: Program terminated with signal SIGSEGV, Segmentation fault. #0 SwViewShell::GetLayout (this=0x0) at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/shared_ptr_base.h:1665 and #0 SwViewShell::GetLayout (this=0x0) at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/shared_ptr_base.h:1665 #1 0x000078c9268a799d in SwViewShell::GetDocSize (this=<optimized out>) at sw/source/core/view/viewsh.cxx:2320 #2 0x000078c926ca55e8 in non-virtual thunk to SwXTextDocument::getDocumentSize() () at sw/inc/unotxdoc.hxx:444 #3 0x000078c933bc4e16 in doc_getDocumentSize (pThis=0x8e8cc20, pWidth=0x7ffdd9b4c5e0, pHeight=0x7ffdd9b4c5e8) at desktop/source/lib/init.cxx:4626 Fix it similar to what SwXTextDocument::setPart() does: don't assume that we still have a view shell by the time getDocumentSize() is called, a document teardown may be in progress where we still have a model, but no views anymore. Change-Id: Id2f5ac4bf08601a9664909f5a78322bf41998a86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197062 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -3381,6 +3381,11 @@ void SwXTextDocument::paintTile( VirtualDevice &rDevice,
|
||||
Size SwXTextDocument::getDocumentSize()
|
||||
{
|
||||
SwViewShell* pViewShell = m_pDocShell->GetWrtShell();
|
||||
if (!pViewShell)
|
||||
{
|
||||
return Size();
|
||||
}
|
||||
|
||||
Size aDocSize = pViewShell->GetDocSize();
|
||||
|
||||
return Size(aDocSize.Width() + 2 * DOCUMENTBORDER,
|
||||
|
||||
Reference in New Issue
Block a user