[Libreoffice-commits] .: 2 commits - svtools/source vcl/inc

Lubos Lunak llunak at kemper.freedesktop.org
Tue May 31 11:58:02 PDT 2011


 svtools/source/misc/imagemgr.cxx |   10 +++++-----
 vcl/inc/vcl/lazydelete.hxx       |    5 +++++
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
commit baa4b962f1c2733ac16821304c9bb1e00f38deae
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue May 31 20:55:53 2011 +0200

    vcl::DeleteOnDeinit for static BitmapEx objects
    
    they should not outlive VCL cleanup (need X connection, etc.)

diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index 3dbcdec..07f7d1d 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -54,7 +54,7 @@
 #include <svtools/imagemgr.hrc>
 #include <svtools/svtdata.hxx>
 #include <osl/mutex.hxx>
-#include <boost/scoped_ptr.hpp>
+#include <vcl/lazydelete.hxx>
 
 // globals *******************************************************************
 
@@ -509,8 +509,8 @@ static Image GetImageFromList_Impl( sal_uInt16 nImageId, sal_Bool bBig )
 
     ImageList* pList = NULL;
 
-    static boost::scoped_ptr<ImageList> xSmallImageList;
-    static boost::scoped_ptr<ImageList> xBigImageList;
+    static vcl::DeleteOnDeinit< ImageList > xSmallImageList( NULL );
+    static vcl::DeleteOnDeinit< ImageList > xBigImageList( NULL );
     static sal_uLong nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
 
     // If the style has been changed, throw away our cache of the older images
@@ -523,13 +523,13 @@ static Image GetImageFromList_Impl( sal_uInt16 nImageId, sal_Bool bBig )
 
     if ( bBig )
     {
-        if ( !xBigImageList )
+        if ( !xBigImageList.get() )
             xBigImageList.reset(new ImageList(SvtResId(RID_SVTOOLS_IMAGELIST_BIG)));
         pList = xBigImageList.get();
     }
     else
     {
-        if ( !xSmallImageList )
+        if ( !xSmallImageList.get() )
             xSmallImageList.reset(new ImageList(SvtResId(RID_SVTOOLS_IMAGELIST_SMALL)));
         pList = xSmallImageList.get();
     }
commit fc0e8d4e9066f2e3ceb91f2251761e3b36b2d9db
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue May 31 20:54:58 2011 +0200

    implement vcl::DeleteOnDeinit::reset()
    
    the class is pretty bad API without it

diff --git a/vcl/inc/vcl/lazydelete.hxx b/vcl/inc/vcl/lazydelete.hxx
index b2615f8..85d54de 100644
--- a/vcl/inc/vcl/lazydelete.hxx
+++ b/vcl/inc/vcl/lazydelete.hxx
@@ -258,6 +258,11 @@ namespace vcl
         // set contents, returning old contents
         // ownership is transfered !
         T* set( T* i_pNew ) { T* pOld = m_pT; m_pT = i_pNew; return pOld; }
+
+        // set contents, deleting old contents
+        // ownership is transfered !
+        void reset( T* i_pNew = NULL )
+            { OSL_ASSERT( i_pNew != m_pT || i_pNew == NULL ); T* pOld = m_pT; m_pT = i_pNew; delete pOld; }
     };
 
     /** Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit


More information about the Libreoffice-commits mailing list