summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-10-31 17:51:46 +0100
committerMichael Stahl <mstahl@redhat.com>2014-10-31 17:55:18 +0100
commitfc9e78f4498a3b44be72e13c0c64d235f62b8a99 (patch)
treed8f45e6eb52365dd38904a48b517449c360de8f3 /framework
parent03cca068ed901d1862c440a6f414d17609785974 (diff)
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
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/toolbarmanager.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index e00a974607a2..bac2210de997 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -243,6 +243,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
ToolBarManager::~ToolBarManager()
{
+ assert(!m_aAsyncUpdateControllersTimer.IsActive());
OSL_ASSERT( m_pToolBar == 0 );
OSL_ASSERT( !m_bAddedToTaskPaneList );
}
@@ -475,7 +476,9 @@ throw ( RuntimeException, std::exception )
{
SolarMutexGuard g;
if ( Action.Action == FrameAction_CONTEXT_CHANGED )
+ {
m_aAsyncUpdateControllersTimer.Start();
+ }
}
void SAL_CALL ToolBarManager::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
@@ -563,9 +566,6 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
{
SolarMutexGuard g;
- // stop timer to prevent timer events after dispose
- m_aAsyncUpdateControllersTimer.Stop();
-
RemoveControllers();
if ( m_xDocImageManager.is() )
@@ -629,6 +629,10 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
m_xModuleAcceleratorManager.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;
}
}
@@ -1412,7 +1416,9 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if( m_pToolBar->WillUsePopupMode() )
UpdateControllers();
else if ( m_pToolBar->IsReallyVisible() )
+ {
m_aAsyncUpdateControllersTimer.Start();
+ }
// Try to retrieve UIName from the container property set and set it as the title
// if it is not empty.
@@ -2038,7 +2044,9 @@ IMPL_LINK( ToolBarManager, StateChanged, StateChangedType*, pStateChangedType )
else if ( *pStateChangedType == StateChangedType::VISIBLE )
{
if ( m_pToolBar->IsReallyVisible() )
+ {
m_aAsyncUpdateControllersTimer.Start();
+ }
}
else if ( *pStateChangedType == StateChangedType::INITSHOW )
{