diff options
Diffstat (limited to 'sfx2/source/view/viewsh.cxx')
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 4a9b9552d5c2..83fd8d2bbefe 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -131,6 +131,8 @@ class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1< public: SfxClipboardChangeListener( SfxViewShell* pView ); virtual ~SfxClipboardChangeListener(); + + void DisconnectViewShell() { pViewShell = NULL; } }; SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView ) @@ -241,7 +243,12 @@ static ::rtl::OUString RetrieveLabelFromCommand( } //========================================================================= +SfxViewShell_Impl::SfxViewShell_Impl() +: aInterceptorContainer( aMutex ) +, pAccExec(0) +{} +//========================================================================= SFX_IMPL_INTERFACE(SfxViewShell,SfxShell,SfxResId(0)) { SFX_CHILDWINDOW_REGISTRATION( SID_MAIL_CHILDWIN ); @@ -1297,21 +1304,27 @@ SfxViewShell::~SfxViewShell() SfxViewShellArr_Impl &rViewArr = SFX_APP()->GetViewShells_Impl(); rViewArr.Remove( rViewArr.GetPos(pThis) ); + if ( pImp->xClipboardListener.is() ) + { + pImp->xClipboardListener->DisconnectViewShell(); + pImp->xClipboardListener = NULL; + } + if ( pImp->pController ) { pImp->pController->ReleaseShell_Impl(); pImp->pController->release(); + pImp->pController = NULL; } if (pImp->pAccExec) { - delete pImp->pAccExec; - pImp->pAccExec = 0; + DELETEZ( pImp->pAccExec ); } - //delete pImp->pPrinterCommandQueue; - delete pImp; - delete pIPClientList; + //DELETEZ( pImp->pPrinterCommandQueue ); + DELETEZ( pImp ); + DELETZ( pIPClientList ); } //-------------------------------------------------------------------- @@ -1997,7 +2010,12 @@ void SfxViewShell::SetController( SfxBaseController* pController ) pImp->pController->acquire(); pImp->bControllerSet = TRUE; - AddRemoveClipboardListener( new SfxClipboardChangeListener( this ), TRUE ); + // there should be no old listener, but if there is one, it should be disconnected + if ( pImp->xClipboardListener.is() ) + pImp->xClipboardListener->DisconnectViewShell(); + + pImp->xClipboardListener = new SfxClipboardChangeListener( this ); + AddRemoveClipboardListener( pImp->xClipboardListener.get(), TRUE ); } Reference < XController > SfxViewShell::GetController() @@ -2218,17 +2236,20 @@ void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransf { try { - uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() ); - if( !xClipboard.is() ) - return; - - uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY ); - if( xClpbrdNtfr.is() ) + if ( GetViewFrame() ) { - if( bAdd ) - xClpbrdNtfr->addClipboardListener( rClp ); - else - xClpbrdNtfr->removeClipboardListener( rClp ); + uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() ); + if( xClipboard.is() ) + { + uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY ); + if( xClpbrdNtfr.is() ) + { + if( bAdd ) + xClpbrdNtfr->addClipboardListener( rClp ); + else + xClpbrdNtfr->removeClipboardListener( rClp ); + } + } } } catch( const uno::Exception& ) |