diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-02-23 16:13:02 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-02-24 14:35:32 +0100 |
commit | b7e3e73b8015e20f8303ea1f2a2156128ae411e2 (patch) | |
tree | 7d38ba9379928703164ff74574d203c8b9f1858f /sw | |
parent | e4b76246055eb8d2b37dbf49684bb7c77068eeb1 (diff) |
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/50256
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/uiview/view1.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/uibase/uiview/view1.cxx b/sw/source/uibase/uiview/view1.cxx index 4f3650a6e7dc..c5c70feaf26c 100644 --- a/sw/source/uibase/uiview/view1.cxx +++ b/sw/source/uibase/uiview/view1.cxx @@ -22,6 +22,7 @@ #include <svx/ruler.hxx> #include <idxmrk.hxx> #include <view.hxx> +#include <basesh.hxx> #include <wrtsh.hxx> #include <swmodule.hxx> #include <viewopt.hxx> @@ -68,6 +69,32 @@ void SwView::Activate(bool 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 if( !m_sSwViewData.isEmpty() ) |