diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-24 11:40:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-24 11:43:54 -0400 |
commit | f6d9b4afbda6cf1a3db822b5fb5125448ef9e1d1 (patch) | |
tree | ac7457d3d9c043bdef2bc5268b0a4686f38bdfb5 /sfx2 | |
parent | 05f786fd2eb8056be946f6aadb21cdd61be8e226 (diff) |
Delete SfxItemSet before the current shell gets destroyed.
SfxItemSet takes hold of the SfxItemPool instance from the current
shell, and accesses it when it gets destroyed. The problem arises
when the current shell gets destroyed before the SfxItemSet instnace
does, in which case an illegal memory access ensues.
This fixes intermittent crashes when opening a document in Writer.
Change-Id: Ib5e74b43051f868f22f6efdb311e6c2a75326d9a
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 005db6e6b1a4..360590f75588 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -67,6 +67,8 @@ #include <sfx2/msgpool.hxx> #include <sfx2/objsh.hxx> +#include <boost/scoped_ptr.hpp> + namespace css = ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -725,16 +727,20 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util } eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); - SfxAllItemSet aSet( pShell->GetPool() ); - TransformParameters( GetId(), lNewArgs, aSet, pSlot ); - if ( aSet.Count() ) + boost::scoped_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); + TransformParameters(GetId(), lNewArgs, *xSet, pSlot); + if (xSet->Count()) { // execute with arguments - call directly - pItem = pDispatcher->Execute( GetId(), nCall, &aSet, &aInternalSet, nModifier ); + pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); bSuccess = (pItem != NULL); } else { + // Be sure to delete this before we send a dispatch + // request, which will destroy the current shell. + xSet.reset(); + // execute using bindings, enables support for toggle/enum etc. SfxRequest aReq( GetId(), nCall, pShell->GetPool() ); aReq.SetModifier( nModifier ); |