[Libreoffice-commits] .: sfx2/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed May 25 19:14:17 PDT 2011


 sfx2/source/control/bindings.cxx |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

New commits:
commit 3b0376644d4632ea7280a327ce1bc865dbaf61c0
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed May 25 22:11:49 2011 -0400

    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.

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 931830f..0b68d9f 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -72,6 +72,7 @@
 #include <comphelper/uieventslogger.hxx>
 #include <com/sun/star/frame/XModuleManager.hpp>
 
+#include <boost/scoped_ptr.hpp>
 
 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<SfxStateCache> 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;
 }
 


More information about the Libreoffice-commits mailing list