framework: avoid double-free in ToolBarManager()
The timer could run after the ToolBarManager is deleted because the dispose() method can accidentally restart the timer somehow. Change-Id: I86868f08f436976761e814d4cea1cd5a0e348935
This commit is contained in:
@@ -243,6 +243,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
|
|||||||
|
|
||||||
ToolBarManager::~ToolBarManager()
|
ToolBarManager::~ToolBarManager()
|
||||||
{
|
{
|
||||||
|
assert(!m_aAsyncUpdateControllersTimer.IsActive());
|
||||||
OSL_ASSERT( m_pToolBar == 0 );
|
OSL_ASSERT( m_pToolBar == 0 );
|
||||||
OSL_ASSERT( !m_bAddedToTaskPaneList );
|
OSL_ASSERT( !m_bAddedToTaskPaneList );
|
||||||
}
|
}
|
||||||
@@ -475,8 +476,10 @@ throw ( RuntimeException, std::exception )
|
|||||||
{
|
{
|
||||||
SolarMutexGuard g;
|
SolarMutexGuard g;
|
||||||
if ( Action.Action == FrameAction_CONTEXT_CHANGED )
|
if ( Action.Action == FrameAction_CONTEXT_CHANGED )
|
||||||
|
{
|
||||||
m_aAsyncUpdateControllersTimer.Start();
|
m_aAsyncUpdateControllersTimer.Start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SAL_CALL ToolBarManager::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
|
void SAL_CALL ToolBarManager::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
|
||||||
throw ( ::com::sun::star::uno::RuntimeException, std::exception )
|
throw ( ::com::sun::star::uno::RuntimeException, std::exception )
|
||||||
@@ -563,9 +566,6 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
|
|||||||
{
|
{
|
||||||
SolarMutexGuard g;
|
SolarMutexGuard g;
|
||||||
|
|
||||||
// stop timer to prevent timer events after dispose
|
|
||||||
m_aAsyncUpdateControllersTimer.Stop();
|
|
||||||
|
|
||||||
RemoveControllers();
|
RemoveControllers();
|
||||||
|
|
||||||
if ( m_xDocImageManager.is() )
|
if ( m_xDocImageManager.is() )
|
||||||
@@ -629,6 +629,10 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
|
|||||||
m_xModuleAcceleratorManager.clear();
|
m_xModuleAcceleratorManager.clear();
|
||||||
m_xDocAcceleratorManager.clear();
|
m_xDocAcceleratorManager.clear();
|
||||||
|
|
||||||
|
// stop timer to prevent timer events after dispose
|
||||||
|
// do it last because other calls could restart timer in StateChanged()
|
||||||
|
m_aAsyncUpdateControllersTimer.Stop();
|
||||||
|
|
||||||
m_bDisposed = true;
|
m_bDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1412,7 +1416,9 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
|
|||||||
if( m_pToolBar->WillUsePopupMode() )
|
if( m_pToolBar->WillUsePopupMode() )
|
||||||
UpdateControllers();
|
UpdateControllers();
|
||||||
else if ( m_pToolBar->IsReallyVisible() )
|
else if ( m_pToolBar->IsReallyVisible() )
|
||||||
|
{
|
||||||
m_aAsyncUpdateControllersTimer.Start();
|
m_aAsyncUpdateControllersTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
// Try to retrieve UIName from the container property set and set it as the title
|
// Try to retrieve UIName from the container property set and set it as the title
|
||||||
// if it is not empty.
|
// if it is not empty.
|
||||||
@@ -2038,8 +2044,10 @@ IMPL_LINK( ToolBarManager, StateChanged, StateChangedType*, pStateChangedType )
|
|||||||
else if ( *pStateChangedType == StateChangedType::VISIBLE )
|
else if ( *pStateChangedType == StateChangedType::VISIBLE )
|
||||||
{
|
{
|
||||||
if ( m_pToolBar->IsReallyVisible() )
|
if ( m_pToolBar->IsReallyVisible() )
|
||||||
|
{
|
||||||
m_aAsyncUpdateControllersTimer.Start();
|
m_aAsyncUpdateControllersTimer.Start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ( *pStateChangedType == StateChangedType::INITSHOW )
|
else if ( *pStateChangedType == StateChangedType::INITSHOW )
|
||||||
{
|
{
|
||||||
m_aAsyncUpdateControllersTimer.Start();
|
m_aAsyncUpdateControllersTimer.Start();
|
||||||
|
Reference in New Issue
Block a user