[Libreoffice-commits] core.git: basic/inc basic/qa basic/source

Noel Grandin noel at peralex.com
Mon Jun 27 05:17:59 UTC 2016


 basic/inc/sbprop.hxx                |    1 -
 basic/qa/cppunit/basic_coverage.cxx |    4 +---
 basic/source/basmgr/basmgr.cxx      |   17 ++++-------------
 basic/source/classes/sbxmod.cxx     |    1 -
 basic/source/comp/scanner.cxx       |    1 -
 basic/source/inc/scanner.hxx        |    1 -
 6 files changed, 5 insertions(+), 20 deletions(-)

New commits:
commit cea4c1afdf4ae0cbda8ae531f2e26d911d0fd6e1
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Jun 24 12:08:25 2016 +0200

    loplugin:singlevalfields in basic and fix leak
    
    And fix leak in BasicManagerImpl where it would never have freed
    the streams.
    
    Change-Id: I1e99c2c6a70a8cac27dd5c86a7042efc3de7a578
    Reviewed-on: https://gerrit.libreoffice.org/26632
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basic/inc/sbprop.hxx b/basic/inc/sbprop.hxx
index 09138ae..fbeb138 100644
--- a/basic/inc/sbprop.hxx
+++ b/basic/inc/sbprop.hxx
@@ -32,7 +32,6 @@ class BASIC_DLLPUBLIC SbProperty : public SbxProperty
     friend class SbModule;
     friend class SbProcedureProperty;
     SbModule* pMod;
-    bool     bInvalid;
     BASIC_DLLPRIVATE SbProperty( const OUString&, SbxDataType, SbModule* );
     virtual ~SbProperty();
 public:
diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx
index 275fdb9..39a8ebc 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -21,7 +21,6 @@ class Coverage : public test::BootstrapFixture
 {
 private:
     int  m_nb_tests_ok;
-    int  m_nb_tests_skipped;
     OUString m_sCurrentTest;
     void process_directory(const OUString& sDirName);
     void run_test(const OUString& sFileName);
@@ -48,13 +47,12 @@ public:
 Coverage::Coverage()
     : BootstrapFixture(true, false)
     , m_nb_tests_ok(0)
-    , m_nb_tests_skipped(0)
 {
 }
 
 Coverage::~Coverage()
 {
-    fprintf(stderr,"basic coverage Summary : skipped:%d pass:%d\n", m_nb_tests_skipped, m_nb_tests_ok );
+    fprintf(stderr,"basic coverage Summary : pass:%d\n", m_nb_tests_ok );
 }
 
 void Coverage::test_failed()
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 918d61d..aeba2e6 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -34,6 +34,7 @@
 #include <unotools/intlwrapper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <basic/sbuno.hxx>
 #include <basic/basmgr.hxx>
@@ -107,16 +108,13 @@ struct BasicManagerImpl
 
     // Save stream data
     SvMemoryStream*  mpManagerStream;
-    SvMemoryStream** mppLibStreams;
-    sal_Int32        mnLibStreamCount;
+    std::vector<std::unique_ptr<SvMemoryStream>> maLibStreams;
 
     std::vector<std::unique_ptr<BasicLibInfo>> aLibs;
     OUString         aBasicLibPath;
 
     BasicManagerImpl()
         : mpManagerStream( nullptr )
-        , mppLibStreams( nullptr )
-        , mnLibStreamCount( 0 )
     {}
     ~BasicManagerImpl();
 };
@@ -124,12 +122,6 @@ struct BasicManagerImpl
 BasicManagerImpl::~BasicManagerImpl()
 {
     delete mpManagerStream;
-    if( mppLibStreams )
-    {
-        for( sal_Int32 i = 0 ; i < mnLibStreamCount ; i++ )
-            delete mppLibStreams[i];
-        delete[] mppLibStreams;
-    }
 }
 
 
@@ -539,13 +531,12 @@ BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, Star
         if( xBasicStorage.Is() && !xBasicStorage->GetError() )
         {
             sal_uInt16 nLibs = GetLibCount();
-            mpImpl->mppLibStreams = new SvMemoryStream*[ nLibs ];
             for( sal_uInt16 nL = 0; nL < nLibs; nL++ )
             {
                 BasicLibInfo& rInfo = *mpImpl->aLibs[nL];
                 tools::SvRef<SotStorageStream> xBasicStream = xBasicStorage->OpenSotStream( rInfo.GetLibName(), eStreamReadMode );
-                mpImpl->mppLibStreams[nL] = new SvMemoryStream();
-                xBasicStream->ReadStream( *( mpImpl->mppLibStreams[nL] ) );
+                mpImpl->maLibStreams.push_back(o3tl::make_unique<SvMemoryStream>());
+                xBasicStream->ReadStream( *mpImpl->maLibStreams.back() );
             }
         }
     }
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 7970f04..f36b9bf 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -2719,7 +2719,6 @@ SbUserFormModule::Find( const OUString& rName, SbxClassType t )
 SbProperty::SbProperty( const OUString& r, SbxDataType t, SbModule* p )
         : SbxProperty( r, t ), pMod( p )
 {
-    bInvalid = false;
 }
 
 SbProperty::~SbProperty()
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 6dfe2c5..968458f 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -31,7 +31,6 @@ SbiScanner::SbiScanner( const OUString& rBuf, StarBASIC* p ) : aBuf( rBuf )
     eScanType = SbxVARIANT;
     nErrors  = 0;
     nBufPos  = 0;
-    nCurCol1 = 0;
     nSavedCol1 = 0;
     nColLock = 0;
     nLine    = 0;
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index d17337e..a7f1377 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -45,7 +45,6 @@ protected:
     OUString aError;
     SbxDataType eScanType;
     double nVal;                        // numeric value
-    sal_Int32 nCurCol1;
     sal_Int32 nSavedCol1;
     sal_Int32 nCol;
     sal_Int32 nErrors;


More information about the Libreoffice-commits mailing list