[Libreoffice-commits] core.git: 3 commits - connectivity/source

Caolán McNamara caolanm at redhat.com
Wed Mar 8 16:16:47 UTC 2017


 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx  |    6 -
 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx  |    5 -
 connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx |   36 +++++-----
 connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx |   10 +-
 4 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit bbbd1f1eec7ce078a37bc3a23a7f1e8ec4070634
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 8 16:09:58 2017 +0000

    valgrind: fix leak
    
    Change-Id: I569698af09dfe71c0c8b89c40ab111ce71635492

diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
index 505a23b..a243ecc 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
@@ -48,8 +48,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void*  SAL_CALL OMozillaBootstrap_CreateInstance
 }
 
 MozillaBootstrap::MozillaBootstrap()
-    : OMozillaBootstrap_BASE(m_aMutex),
-      m_ProfileAccess(nullptr)
+    : OMozillaBootstrap_BASE(m_aMutex)
 {
 }
 
@@ -59,11 +58,10 @@ MozillaBootstrap::~MozillaBootstrap()
 
 void MozillaBootstrap::Init()
 {
-    m_ProfileAccess = new ProfileAccess();
+    m_ProfileAccess.reset(new ProfileAccess);
     bootupProfile(css::mozilla::MozillaProductType_Mozilla,OUString());
 }
 
-
 void MozillaBootstrap::disposing()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
index de921e9..25e68a9 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
@@ -40,7 +40,7 @@ namespace connectivity
         private:
             ::osl::Mutex                m_aMutex;       // mutex is need to control member access
             virtual ~MozillaBootstrap() override;
-            ProfileAccess * m_ProfileAccess;
+            std::unique_ptr<ProfileAccess> m_ProfileAccess;
         public:
 
             void Init();
commit 4f61fdba534fa808edeb86a52f9ffc9fe528c28e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 8 16:09:01 2017 +0000

    nothing inherits, protected->private
    
    Change-Id: I254ffe76603a9c5900ea2ed26d281eba453c059d

diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
index 9c75568..de921e9 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
@@ -37,10 +37,9 @@ namespace connectivity
         class ProfileManager;
         class MozillaBootstrap : public OMozillaBootstrap_BASE
         {
-        protected:
+        private:
             ::osl::Mutex                m_aMutex;       // mutex is need to control member access
             virtual ~MozillaBootstrap() override;
-        protected:
             ProfileAccess * m_ProfileAccess;
         public:
 
commit 14881451de9dfba0ca783c695e0c538ae72e6736
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 8 15:56:52 2017 +0000

    valgrind: fix leak
    
    Change-Id: I8510a59a3d4409bf7203495114e239b4c7effcd8

diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
index 1adb899..b2ef4d9 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
@@ -26,15 +26,21 @@ namespace connectivity
 {
     namespace mozab
     {
-        ProfileStruct::ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName,
-            const OUString& aProfilePath
-          )
+        ProfileStruct::ProfileStruct()
+            : product(css::mozilla::MozillaProductType_Default)
         {
-            product=aProduct;
-            profileName = aProfileName;
-            profilePath = aProfilePath;
         }
-        const OUString& ProfileStruct::getProfilePath()
+
+        ProfileStruct::ProfileStruct(MozillaProductType aProduct,
+                                     const OUString& aProfileName,
+                                     const OUString& aProfilePath)
+            : product(aProduct)
+            , profileName(aProfileName)
+            , profilePath(aProfilePath)
+        {
+        }
+
+        const OUString& ProfileStruct::getProfilePath() const
         {
             return profilePath;
         }
@@ -42,6 +48,7 @@ namespace connectivity
         ProfileAccess::~ProfileAccess()
         {
         }
+
         ProfileAccess::ProfileAccess()
         {
             LoadProductsInfo();
@@ -121,10 +128,7 @@ namespace connectivity
                         fullProfilePath = profilePath;
                     }
 
-                    ProfileStruct*  profileItem     = new ProfileStruct(product,profileName,
-                            fullProfilePath
-                        );
-                    rProduct.mProfileList[profileName] = profileItem;
+                    rProduct.mProfileList[profileName] = ProfileStruct(product,profileName,fullProfilePath);
 
                     sal_Int32 isDefault = 0;
                     if (!sIsDefault.isEmpty())
@@ -149,7 +153,7 @@ namespace connectivity
                 return OUString();
             }
             else
-                return rProduct.mProfileList[profileName]->getProfilePath();
+                return rProduct.mProfileList[profileName].getProfilePath();
         }
 
         ::sal_Int32 ProfileAccess::getProfileCount( css::mozilla::MozillaProductType product)
@@ -168,8 +172,8 @@ namespace connectivity
                 itor != rProduct.mProfileList.end();
                 ++itor)
             {
-                ProfileStruct * aProfile = (*itor).second;
-                list[i] = aProfile->getProfileName();
+                const ProfileStruct& rProfile = (*itor).second;
+                list[i] = rProfile.getProfileName();
                 i++;
             }
 
@@ -190,8 +194,8 @@ namespace connectivity
                 //there are not any profiles
                 return OUString();
             }
-            ProfileStruct * aProfile = (*rProduct.mProfileList.begin()).second;
-            return aProfile->getProfileName();
+            const ProfileStruct& rProfile = (*rProduct.mProfileList.begin()).second;
+            return rProfile.getProfileName();
         }
         bool ProfileAccess::isProfileLocked( css::mozilla::MozillaProductType product, const OUString& profileName )
         {
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
index 6cb9efe..395724f 100644
--- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
@@ -39,7 +39,7 @@ namespace connectivity
         class ProfileStruct;
     }
 }
-typedef std::map < OUString, ::connectivity::mozab::ProfileStruct* > ProfileList;
+typedef std::map<OUString, ::connectivity::mozab::ProfileStruct> ProfileList;
 namespace connectivity
 {
     namespace mozab
@@ -47,10 +47,10 @@ namespace connectivity
         class ProfileStruct
         {
         public:
-            ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName,
-                          const OUString &aProfilePath);
-            const OUString& getProfileName(){ return profileName;}
-            const OUString& getProfilePath();
+            ProfileStruct();
+            ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName, const OUString &aProfilePath);
+            const OUString& getProfileName() const { return profileName;}
+            const OUString& getProfilePath() const;
         private:
             MozillaProductType product;
             OUString profileName;


More information about the Libreoffice-commits mailing list