From 844d09c4cf6d08bb58e1b37a5ee7335320880654 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 25 May 2011 22:11:49 -0400 Subject: Don't delete pCache too early; we need it alive to get the slot server. Let's use boost::scopted_ptr to avoid memory leak instead. The previous code caused data input in Calc to fail for the first two times in new document. --- sfx2/source/control/bindings.cxx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 931830f4c7..0b68d9f11e 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -72,6 +72,7 @@ #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1144,14 +1145,14 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem* rDispatcher.GetFrame(); // -Wall is this required??? // get SlotServer (Slot+ShellLevel) and Shell from cache - sal_Bool bDeleteCache = sal_False; + ::boost::scoped_ptr xCache; if ( !pCache ) { // Execution of non cached slots (Accelerators don't use Controllers) // slot is uncached, use SlotCache to handle external dispatch providers - pCache = new SfxStateCache( nId ); + xCache.reset(new SfxStateCache(nId)); + pCache = xCache.get(); pCache->GetSlotServer( rDispatcher, pImp->xProv ); - bDeleteCache = sal_True; } if ( pCache && pCache->GetDispatch().is() ) @@ -1167,14 +1168,10 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem* // cache binds to an external dispatch provider pCache->Dispatch( aReq.GetArgs(), nCallMode == SFX_CALLMODE_SYNCHRON ); - if ( bDeleteCache ) - DELETEZ( pCache ); SfxPoolItem *pVoid = new SfxVoidItem( nId ); DeleteItemOnIdle( pVoid ); return pVoid; } - else if ( pCache && bDeleteCache ) // just in case it was created, but GetDispatch() is 0 - DELETEZ( pCache ); // slot is handled internally by SfxDispatcher if ( pImp->bMsgDirty ) @@ -1224,9 +1221,6 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem* pRet = pVoid; } - if ( bDeleteCache ) - delete pCache; - return pRet; } -- cgit v1.2.3