Commits

Anonymous committed 8e1d566

contextmenu1: the SfxBaseController should release its interceptors from the LayoutManager on disposing, otherwise the LayoutManager will keep notifying them

  • Participants
  • Parent commits ff8eb2f

Comments (0)

Files changed (2)

File sfx2/inc/sfx2/sfxbasecontroller.hxx

     };
     SAL_DLLPRIVATE void ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect );
     SAL_DLLPRIVATE SfxViewFrame& GetViewFrame_Impl() const;
+    SAL_DLLPRIVATE void ReleaseContextMenuInterceptors_Impl();
 
 //________________________________________________________________________________________________________
 //	private variables

File sfx2/source/view/sfxbasecontroller.cxx

     aEventObject.Source = *this ;
 	m_pData->m_aListenerContainer.disposeAndClear( aEventObject ) ;
 
+    // release registered context menu interceptors
+    ReleaseContextMenuInterceptors_Impl();
+    m_pData->m_aInterceptorContainer.clear();
+
     if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() )
         m_pData->m_pController->getFrame()->removeFrameActionListener( m_pData->m_xListener ) ;
 
     }
 }
 
+void SfxBaseController::ReleaseContextMenuInterceptors_Impl()
+{
+    try
+    {
+        uno::Reference< beans::XPropertySet > xFrameProps( getFrame(), uno::UNO_QUERY );
+        uno::Reference< ui::XContextMenuInterception > xLayoutManager;
+        if ( xFrameProps.is()
+            && ( xFrameProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= xLayoutManager )
+            && xLayoutManager.is() )
+        {
+            ::cppu::OInterfaceIteratorHelper aIt( m_pData->m_aInterceptorContainer );
+            while ( aIt.hasMoreElements() )
+            {
+                try
+                {
+                    xLayoutManager->releaseContextMenuInterceptor( static_cast< ui::XContextMenuInterceptor* >( aIt.next() ) );
+                }
+                catch ( const uno::Exception& )
+                {
+                }
+            }
+        }
+    }
+    catch( const uno::Exception& )
+    {
+    }
+}
+
 void SAL_CALL SfxBaseController::addKeyHandler( const ::com::sun::star::uno::Reference< XKEYHANDLER >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
 {
 	::vos::OGuard aGuard( Application::GetSolarMutex() );