summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-11-28 18:39:52 +0100
committerMichael Stahl <mstahl@redhat.com>2014-11-28 19:17:02 +0100
commit426ef2847cbdc74c068531915efb852a727cd3ee (patch)
tree55f4ff147de832a5d7db95b0843a210ab93ee3e1 /chart2
parentc1e1757cdab6e61b94244761227b0a1f112e6b0c (diff)
chart2: ChartController: fix CommandDispatchContainer access locking
crashes on concurrent setModel() and getDispatchForURL() in JunitTest_chart2_unoapi: Thread 13: 7 in (anonymous namespace)::Frame::isActionLocked (this=0x2b66c0e4a090) at /home/tinderbox/master/framework/source/services/frame.cxx:2596 8 in (anonymous namespace)::Frame::close (this=0x2b66c0e4a090, bDeliverOwnership=0 '\000') at /home/tinderbox/master/framework/source/services/frame.cxx:1772 9 in chart::ChartController::notifyClosing (this=0x2b668ae41058, rSource=...) at /home/tinderbox/master/chart2/source/controller/main/ChartController.cxx:872 10 in apphelper::CloseableLifeTimeManager::impl_doClose (this=0x2b669a0b1d08) at /home/tinderbox/master/chart2/source/tools/LifeTime.cxx:360 11 in apphelper::CloseableLifeTimeManager::g_close_endTryClose_doClose (this=0x2b669a0b1d08) at /home/tinderbox/master/chart2/source/tools/LifeTime.cxx:311 12 in chart::ChartModel::close (this=0x2b669a0b1c28, bDeliverOwnership=1 '\001') at /home/tinderbox/master/chart2/source/model/main/ChartModel.cxx:659 Thread 1: 4 in std::__debug::map<rtl::OUString, com::sun::star::uno::Reference<com::sun::star::frame::XDispatch>, std::less<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, com::sun::star::uno::Reference<com::sun::star::frame::XDispatch> > > >::find (this=0x2b668ae41248, __x=...) at /usr/include/c++/4.8.3/debug/map.h:382 No locals. 5 in chart::CommandDispatchContainer::getDispatchForURL (this=0x2b668ae41248, rURL=...) at /home/tinderbox/master/chart2/source/controller/main/CommandDispatchContainer.cxx:80 6 in chart::ChartController::queryDispatch (this=0x2b668ae41058, rURL=..., rTargetFrameName=...) at /home/tinderbox/master/chart2/source/controller/main/ChartController.cxx:1003 No locals. 7 in framework::DispatchProvider::implts_queryFrameDispatch (this=0x2b66a3fd21e8, xFrame=..., aURL=..., sTargetFrameName=..., nSearchFlags=0) at /home/tinderbox/master/framework/source/dispatch/dispatchprovider.cxx:374 8 in framework::DispatchProvider::queryDispatch (this=0x2b66a3fd21e8, aURL=..., sTargetFrameName=..., nSearchFlags=0) at /home/tinderbox/master/framework/source/dispatch/dispatchprovider.cxx:111 9 in framework::InterceptionHelper::queryDispatch (this=0x2b668a61bc08, aURL=..., sTargetFrameName=..., nSearchFlags=0) at /home/tinderbox/master/framework/source/dispatch/interceptionhelper.cxx:78 10 in (anonymous namespace)::Frame::queryDispatch (this=0x2b66c0e4a090, aURL=..., sTargetFrameName=..., nSearchFlags=0) at /home/tinderbox/master/framework/source/services/frame.cxx:2227 11 in svt::ToolboxController::bindListener (this=0x2b66c0f72740) at /home/tinderbox/master/svtools/source/uno/toolboxcontroller.cxx:529 12 in svt::ToolboxController::update (this=0x2b66c0f72740) at /home/tinderbox/master/svtools/source/uno/toolboxcontroller.cxx:232 13 in framework::ToolBarManager::UpdateControllers (this=0x2b669a0a1728) at /home/tinderbox/master/framework/source/uielement/toolbarmanager.cxx:440 14 in framework::ToolBarManager::AsyncUpdateControllersHdl (this=0x2b669a0a1728) at /home/tinderbox/master/framework/source/uielement/toolbarmanager.cxx:2110 15 in framework::ToolBarManager::LinkStubAsyncUpdateControllersHdl (pThis=0x2b669a0a1728, pCaller=0x2b669a0a1890) at /home/tinderbox/master/framework/source/uielement/toolbarmanager.cxx:2097 16 in Link::Call (this=0x2b669a0a18b0, pCaller=0x2b669a0a1890) at /home/tinderbox/master/include/tools/link.hxx:139 17 in Timer::Timeout (this=0x2b669a0a1890) at /home/tinderbox/master/vcl/source/app/timer.cxx:276 Change-Id: I17ef63db8f7c288460e00031e8e8a5c3e4d086b3
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ChartController.cxx16
-rw-r--r--chart2/source/controller/main/ControllerCommandDispatch.cxx9
2 files changed, 21 insertions, 4 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index a9ff0c64798f..7accfe9fa06e 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -491,10 +491,10 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
//is called to attach the controller to a new model.
//return true if attach was successfully, false otherwise (e.g. if you do not work with a model)
- SolarMutexClearableGuard aClearableGuard;
+ SolarMutexResettableGuard aGuard;
if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended?
return sal_False; //behave passive if already disposed or suspended
- aClearableGuard.clear();
+ aGuard.clear();
TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex);
TheModelRef aOldModelRef(m_aModel,m_aModelMutex);
@@ -519,6 +519,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
//--handle relations to the new model
aNewModelRef->addListener( this );
+ aGuard.reset(); // lock for m_aDispatchContainer access
// set new model at dispatchers
m_aDispatchContainer.setModel( aNewModelRef->getModel());
ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this, &m_aDispatchContainer );
@@ -542,6 +543,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
pShapeController->initialize();
m_aDispatchContainer.setShapeController( pShapeController );
}
+ aGuard.clear();
#ifdef TEST_ENABLE_MODIFY_LISTENER
uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY );
@@ -565,7 +567,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
//the frameloader is responsible to call xModel->connectController
{
- SolarMutexGuard aGuard;
+ SolarMutexGuard aGuard2;
if( m_pChartWindow )
m_pChartWindow->Invalidate();
}
@@ -784,6 +786,7 @@ void SAL_CALL ChartController::dispose()
//// @todo integrate specialized implementation
//e.g. release further resources and references
+ SolarMutexGuard g;
m_aDispatchContainer.DisposeAndClear();
}
catch( const uno::Exception & ex )
@@ -894,7 +897,10 @@ bool ChartController::impl_releaseThisModel(
}
}
if( bReleaseModel )
+ {
+ SolarMutexGuard g;
m_aDispatchContainer.setModel( 0 );
+ }
return bReleaseModel;
}
@@ -997,6 +1003,8 @@ uno::Reference<frame::XDispatch> SAL_CALL
sal_Int32 /* nSearchFlags */)
throw(uno::RuntimeException, std::exception)
{
+ SolarMutexGuard aGuard;
+
if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() )
{
if( !rTargetFrameName.isEmpty() && rTargetFrameName == "_self" )
@@ -1010,6 +1018,8 @@ uno::Sequence<uno::Reference<frame::XDispatch > >
const uno::Sequence<frame::DispatchDescriptor>& xDescripts )
throw(uno::RuntimeException, std::exception)
{
+ SolarMutexGuard g;
+
if ( !m_aLifeTimeManager.impl_isDisposed() )
{
return m_aDispatchContainer.getDispatchesForURLs( xDescripts );
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index 7f4f4c18a59e..e28fbe8c03dc 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -32,6 +32,8 @@
#include "StatisticsHelper.hxx"
#include "ShapeController.hxx"
+#include <vcl/svapp.hxx>
+
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -698,7 +700,12 @@ bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
bool ControllerCommandDispatch::isShapeControllerCommandAvailable( const OUString& rCommand )
{
- ShapeController* pShapeController = ( m_pDispatchContainer ? m_pDispatchContainer->getShapeController() : NULL );
+ ShapeController* pShapeController(0);
+ {
+ SolarMutexGuard g;
+ if (m_pDispatchContainer)
+ pShapeController = m_pDispatchContainer->getShapeController();
+ }
if ( pShapeController )
{
FeatureState aState( pShapeController->getState( rCommand ) );