[Libreoffice-commits] .: 8 commits - sfx2/source shell/source

David Tardon dtardon at kemper.freedesktop.org
Tue May 17 21:08:44 PDT 2011


 sfx2/source/appl/shutdowniconunx.cxx    |   10 +++-------
 sfx2/source/config/evntconf.cxx         |   16 ++++++----------
 sfx2/source/control/bindings.cxx        |    2 ++
 sfx2/source/control/statcach.cxx        |    2 +-
 sfx2/source/dialog/templdlg.cxx         |    5 +++--
 sfx2/source/view/orgmgr.cxx             |   14 +++++---------
 shell/source/unix/misc/gnome-open-url.c |   22 ----------------------
 7 files changed, 20 insertions(+), 51 deletions(-)

New commits:
commit dda7650cff35f0f61e8580b2350d2096226326fd
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 14:34:14 2011 +0200

    remove dead code

diff --git a/shell/source/unix/misc/gnome-open-url.c b/shell/source/unix/misc/gnome-open-url.c
index 0c3058d..eaf134b 100755
--- a/shell/source/unix/misc/gnome-open-url.c
+++ b/shell/source/unix/misc/gnome-open-url.c
@@ -47,28 +47,6 @@ typedef enum {
   GNOME_VFS_OK
 } GnomeVFSResult;
 
-
-/*
- * HACK: avoid error messages caused by not setting a GNOME program name
- */
- 
-gchar* gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey)
-{
-    void* handle = dlopen("libglib-2.0.so.0", RTLD_LAZY);
-    
-    (void)subkey; /* avoid warning due to unused parameter */
-
-    if( NULL != handle )
-    {
-        gchar* (* g_strdup)(const gchar*) = (gchar* (*)(const gchar*)) dlsym(handle, "g_strdup");
-        
-        if( NULL != g_strdup)
-            return g_strdup("/apps/gnome-settings/gnome-open-url");
-    }
-    
-    return NULL;        
-}
-
 /*
  * Wrapper function which extracs gnome_url_show from libgnome
  */
commit 156afda4b662b054a0cb0c0f6391cf0c000c9d59
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 14:29:14 2011 +0200

    do not leak memory

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index a0f4137..96125ba 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -29,6 +29,8 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sfx2.hxx"
 
+#include <boost/scoped_ptr.hpp>
+
 #include <vcl/menu.hxx>
 #include <svl/intitem.hxx>
 #include <svl/stritem.hxx>
@@ -2562,7 +2564,7 @@ IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox )
             TIB_DROPDOWN == (pBox->GetItemBits(nEntry)&TIB_DROPDOWN))
     {
         //create a popup menu in Writer
-        PopupMenu *pMenu = new PopupMenu;
+        boost::scoped_ptr<PopupMenu> pMenu(new PopupMenu);
         uno::Reference< container::XNameAccess > xNameAccess(
                     ::comphelper::getProcessServiceFactory()->
                     createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
@@ -2607,7 +2609,6 @@ IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox )
         catch(uno::Exception&)
         {
         }
-        delete pMenu;
         pBox->Invalidate();
     }
     return 0;
commit 79901bf9ad29b8037de4550ac9382ffd8ad4cfce
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 14:19:22 2011 +0200

    do not leak memory

diff --git a/sfx2/source/view/orgmgr.cxx b/sfx2/source/view/orgmgr.cxx
index 5a6c922..58a1b31 100644
--- a/sfx2/source/view/orgmgr.cxx
+++ b/sfx2/source/view/orgmgr.cxx
@@ -491,26 +491,22 @@ sal_Bool	SfxOrganizeMgr::Delete(SfxOrganizeListBox_Impl *pCaller,
         if ( pGroupToDelete )
         {
             sal_uInt16 nItemNum = (sal_uInt16)( pCaller->GetModel()->GetChildCount( pGroupToDelete ) );
-            sal_uInt16 nToDeleteNum = 0;
-            SvLBoxEntry **pEntriesToDelete = new SvLBoxEntry*[nItemNum];
+            typedef std::deque<SvLBoxEntry*> BoxEntries;
+            BoxEntries pEntriesToDelete;
 
             sal_uInt16 nInd = 0;
             for ( nInd = 0; nInd < nItemNum; nInd++ )
-                pEntriesToDelete[nInd] = NULL;
-
-            for ( nInd = 0; nInd < nItemNum; nInd++ )
             {
                 // TODO/LATER: check that nInd is the same index that is used in pTemplates
                 if ( pTemplates->Delete( nRegion, nInd ) )
                 {
                     bModified = 1;
-                    pEntriesToDelete[nToDeleteNum++] = pCaller->SvLBox::GetEntry( pGroupToDelete, nInd );
+                    pEntriesToDelete.push_back( pCaller->SvLBox::GetEntry( pGroupToDelete, nInd ) );
                 }
             }
 
-            for ( nInd = 0; nInd < nToDeleteNum; nInd++ )
-                if ( pEntriesToDelete[nInd] )
-                    pCaller->GetModel()->Remove( pEntriesToDelete[nInd] );
+            for ( BoxEntries::const_iterator aIt( pEntriesToDelete.begin() ), aEnd( pEntriesToDelete.end() ); aIt != aEnd; ++aIt )
+                pCaller->GetModel()->Remove( *aIt );
 
             if ( !pCaller->GetModel()->GetChildCount( pGroupToDelete ) )
             {
commit 8031e734a4f72fe80b17b8b0b5260dcb2d2dd788
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 12:54:00 2011 +0200

    fix brain fart

diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx
index d2ec576..7cd76e0 100644
--- a/sfx2/source/control/statcach.cxx
+++ b/sfx2/source/control/statcach.cxx
@@ -410,7 +410,7 @@ void SfxStateCache::SetVisibleState( sal_Bool bShow )
         if ( pInternalController )
             pInternalController->StateChanged( nId, eState, pState );
 
-        if ( !bDeleteItem )
+        if ( bDeleteItem )
             delete pState;
     }
 }
commit 04a197508a5afed9405cfcb59bf4479b4fe8d4ba
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 12:51:15 2011 +0200

    do not leak memory

diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx
index 476c49b..0a2e1e0 100644
--- a/sfx2/source/config/evntconf.cxx
+++ b/sfx2/source/config/evntconf.cxx
@@ -28,6 +28,9 @@
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sfx2.hxx"
+
+#include <boost/scoped_ptr.hpp>
+
 #include <vcl/msgbox.hxx>
 #include <tools/resary.hxx>
 #include <svl/lstner.hxx>
@@ -270,10 +273,10 @@ void PropagateEvent_Impl( SfxObjectShell *pDoc, rtl::OUString aEventName, const
 //--------------------------------------------------------------------------------------------------------
 void SfxEventConfiguration::ConfigureEvent( rtl::OUString aName, const SvxMacro& rMacro, SfxObjectShell *pDoc )
 {
-    SvxMacro *pMacro = NULL;
+    boost::scoped_ptr<SvxMacro> pMacro;
     if ( rMacro.GetMacName().Len() )
-        pMacro = new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() );
-    PropagateEvent_Impl( pDoc ? pDoc : 0, aName, pMacro );
+        pMacro.reset( new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() ) );
+    PropagateEvent_Impl( pDoc ? pDoc : 0, aName, pMacro.get() );
 }
 
 // -------------------------------------------------------------------------------------------------------
commit 481bc5b5edda1c2b2dfbcab12b84ef9f69bf96b4
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 12:46:12 2011 +0200

    simplify

diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx
index b4b4b88..476c49b 100644
--- a/sfx2/source/config/evntconf.cxx
+++ b/sfx2/source/config/evntconf.cxx
@@ -273,14 +273,7 @@ void SfxEventConfiguration::ConfigureEvent( rtl::OUString aName, const SvxMacro&
     SvxMacro *pMacro = NULL;
     if ( rMacro.GetMacName().Len() )
         pMacro = new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() );
-    if ( pDoc )
-    {
-        PropagateEvent_Impl( pDoc, aName, pMacro );
-    }
-    else
-    {
-        PropagateEvent_Impl( NULL, aName, pMacro );
-    }
+    PropagateEvent_Impl( pDoc ? pDoc : 0, aName, pMacro );
 }
 
 // -------------------------------------------------------------------------------------------------------
commit 4e745ff02fc0b9779786a95149d0ca5ffe5b0ed9
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 12:45:43 2011 +0200

    avoid memory leak

diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx
index d8c33ec..5e70016 100644
--- a/sfx2/source/appl/shutdowniconunx.cxx
+++ b/sfx2/source/appl/shutdowniconunx.cxx
@@ -90,10 +90,10 @@ static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId )
     Bitmap pInSalBitmap = aIcon.GetBitmap();
     AlphaMask pInSalAlpha = aIcon.GetAlpha();
 
-    BitmapReadAccess* pSalBitmap = pInSalBitmap.AcquireReadAccess();
-    BitmapReadAccess* pSalAlpha = pInSalAlpha.AcquireReadAccess();
+    Bitmap::ScopedReadAccess pSalBitmap(pInSalBitmap);
+    AlphaMask::ScopedReadAccess pSalAlpha(pInSalAlpha);
 
-    g_return_val_if_fail( pSalBitmap != NULL, NULL );
+    g_return_val_if_fail( pSalBitmap, NULL );
 
     Size aSize( pSalBitmap->Width(), pSalBitmap->Height() );
     if (pSalAlpha)
@@ -123,10 +123,6 @@ static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId )
         }
     }
 
-    pInSalBitmap.ReleaseAccess( pSalBitmap );
-    if( pSalAlpha )
-        pInSalAlpha.ReleaseAccess( pSalAlpha );
-
     return gdk_pixbuf_new_from_data( pPixbufData,
         GDK_COLORSPACE_RGB, sal_True, 8,
         aSize.Width(), aSize.Height(),
commit c6d929b9802b55d420e4e5b55e6044bd2bf33c47
Author: David Tardon <dtardon at redhat.com>
Date:   Tue May 17 08:54:42 2011 +0200

    avoid possible memory leak

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 3df8ce2..049ec70 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1173,6 +1173,8 @@ const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem*
         DeleteItemOnIdle( pVoid );
         return pVoid;
     }
+    else if ( pCache )  // just in case it was created, but GetDispatch() is 0
+        DELETEZ( pCache );
 
     // slot is handled internally by SfxDispatcher
     if ( pImp->bMsgDirty )


More information about the Libreoffice-commits mailing list