Kaydet (Commit) b7e3e73b authored tarafından Katarina Behrens's avatar Katarina Behrens Kaydeden (comit) Thorsten Behrens

Make shell stack more robust against rogue extensions

It shouldn't happen that a view is placed above the shells
it has spawned on sfx2 dispatcher's shell stack 'cause
during dispose, such view gets deleted before the shells
that still refer to it.

Alas it does happen with Wollmux (which makes couple of
Writer UNO API calls before SwView is activated) so guard
against that

Change-Id: Ic7f21992c5e55a48c63dffc733c8f5b0a59a9126
Reviewed-on: https://gerrit.libreoffice.org/50256Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst e4b76246
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <svx/ruler.hxx> #include <svx/ruler.hxx>
#include <idxmrk.hxx> #include <idxmrk.hxx>
#include <view.hxx> #include <view.hxx>
#include <basesh.hxx>
#include <wrtsh.hxx> #include <wrtsh.hxx>
#include <swmodule.hxx> #include <swmodule.hxx>
#include <viewopt.hxx> #include <viewopt.hxx>
...@@ -68,6 +69,32 @@ void SwView::Activate(bool bMDIActivate) ...@@ -68,6 +69,32 @@ void SwView::Activate(bool bMDIActivate)
if ( bMDIActivate ) if ( bMDIActivate )
{ {
if ( m_pShell )
{
SfxDispatcher &rDispatcher = GetDispatcher();
SfxShell *pTopShell = rDispatcher.GetShell( 0 );
// this SwView is the top-most shell on the stack
if ( pTopShell == this )
{
for ( sal_uInt16 i = 1; true; ++i )
{
SfxShell *pSfxShell = rDispatcher.GetShell( i );
// does the stack contain any shells spawned by this SwView already?
if ( ( dynamic_cast< const SwBaseShell *>( pSfxShell ) != nullptr
|| dynamic_cast< const FmFormShell *>( pSfxShell ) != nullptr )
&& ( pSfxShell->GetViewShell() == this ) )
{
// it shouldn't b/c we haven't been activated yet
// so assert that 'cause it'll crash during dispose at the latest
assert( pSfxShell && "Corrupted shell stack: dependent shell positioned below its view");
}
else
break;
}
}
}
m_pWrtShell->ShellGetFocus(); // Selections visible m_pWrtShell->ShellGetFocus(); // Selections visible
if( !m_sSwViewData.isEmpty() ) if( !m_sSwViewData.isEmpty() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment