summaryrefslogtreecommitdiff
path: root/sfx2/source/view/viewsh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/view/viewsh.cxx')
-rw-r--r--sfx2/source/view/viewsh.cxx53
1 files changed, 37 insertions, 16 deletions
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 7d41d2bfa0..a16439698e 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 );
+ DELETEZ( pIPClientList );
}
//--------------------------------------------------------------------
@@ -1996,8 +2009,13 @@ void SfxViewShell::SetController( SfxBaseController* pController )
pImp->pController = pController;
pImp->pController->acquire();
pImp->bControllerSet = TRUE;
+
+ // there should be no old listener, but if there is one, it should be disconnected
+ if ( pImp->xClipboardListener.is() )
+ pImp->xClipboardListener->DisconnectViewShell();
- AddRemoveClipboardListener( new SfxClipboardChangeListener( this ), TRUE );
+ pImp->xClipboardListener = new SfxClipboardChangeListener( this );
+ AddRemoveClipboardListener( pImp->xClipboardListener.get(), TRUE );
}
Reference < XController > SfxViewShell::GetController()
@@ -2205,17 +2223,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& )