[Libreoffice-commits] core.git: 15 commits - package/source sc/source sd/source sfx2/source sw/source vcl/source

Michael Stahl mstahl at redhat.com
Thu Mar 12 12:31:45 PDT 2015


 package/source/xstor/owriteablestream.cxx |   73 +++++++++++++++-----------
 package/source/xstor/owriteablestream.hxx |   23 +-------
 package/source/xstor/xstorage.cxx         |   82 ++++++++++--------------------
 package/source/xstor/xstorage.hxx         |    3 -
 sc/source/core/data/formulacell.cxx       |    3 -
 sd/source/ui/func/fupoor.cxx              |    2 
 sd/source/ui/view/sdwindow.cxx            |    6 +-
 sfx2/source/appl/shutdownicon.cxx         |    2 
 sfx2/source/control/bindings.cxx          |    7 +-
 sfx2/source/control/unoctitm.cxx          |    6 +-
 sw/source/core/doc/docbm.cxx              |    5 +
 vcl/source/control/lstbox.cxx             |    1 
 vcl/source/window/menubarwindow.cxx       |   13 +---
 13 files changed, 100 insertions(+), 126 deletions(-)

New commits:
commit 20abcfcf3e76892fe1edbf5afcae5024ada738c0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 20:09:28 2015 +0100

    sd: PVS-Studio V595 'mpViewShell' pointer could be null
    
    Change-Id: I772aff5997f7630832a07c171cc49ac92908d855

diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 6c70e19..8a79750 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -740,11 +740,15 @@ void Window::DataChanged( const DataChangedEvent& rDCEvt )
             // factor of the frame to always display the whole page.
             const AllSettings* pOldSettings = rDCEvt.GetOldSettings ();
             const AllSettings& rNewSettings = GetSettings ();
-            if (pOldSettings)
+            if (pOldSettings && mpViewShell)
+            {
                 if (pOldSettings->GetStyleSettings().GetScreenZoom()
                     != rNewSettings.GetStyleSettings().GetScreenZoom())
+                {
                     mpViewShell->GetViewFrame()->GetDispatcher()->
                         Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
+                }
+            }
 
             /* Rearrange or initiate Resize for scroll bars since the size of
                the scroll bars my have changed. Within this, inside the resize-
commit 259799f750d33321d7da8523c674e3c775f75005
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:55:36 2015 +0100

    sd: PVS-Studio V595 'mpViewShell' pointer could be null
    
    Change-Id: I214fcfa300d2b75568f90fefa0bc752f90bf3a4d

diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index 6097b3b..0507279 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -202,7 +202,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
         {
             if(rKEvt.GetKeyCode().IsMod1())
             {
-                if(mpViewShell && mpViewShell->ISA(DrawViewShell))
+                if (mpViewShell->ISA(DrawViewShell))
                 {
                     DrawViewShell* pDrawViewShell =
                         static_cast<DrawViewShell*>(mpViewShell);
commit 26f76420c0bcd002d2bfc17a017d373ea5396a9c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:49:03 2015 +0100

    sc: PVS-Studio V595 'pCode' pointer could be null
    
    Change-Id: I2400fde32a41395f5c118f80661ae2c2f21df7ad

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 55e692b..bf97845 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1254,8 +1254,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr
     pDocument->DecXMLImportedFormulaCount( aFormula.getLength() );
     rProgress.SetStateCountDownOnPercent( pDocument->GetXMLImportedFormulaCount() );
     // pCode may not deleted for queries, but must be empty
-    if ( pCode )
-        pCode->Clear();
+    pCode->Clear();
 
     bool bSkipCompile = false;
 
commit ae09c25c0a94ef87b66117f6b27ee660b0b4d3d1
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:43:54 2015 +0100

    sfx2: PVS-Studio V595 'pLastState' pointer could be null
    
    ... actually not but perhaps removing the pointless duplication helps.
    
    Change-Id: I004fea113674703264d22eb9c7a397916e85a2f6

diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index d687a5d..45bd65e 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -974,11 +974,11 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
     {
         if ( !pState->ISA( SfxVisibilityItem ) )
         {
-            bool bBothAvailable = pLastState && !IsInvalidItem(pLastState);
-            if ( bBothAvailable )
+            if (pLastState && !IsInvalidItem(pLastState))
+            {
                 bNotify = pState->Type() != pLastState->Type() || *pState != *pLastState;
-            if ( pLastState && !IsInvalidItem( pLastState ) )
                 delete pLastState;
+            }
             pLastState = !IsInvalidItem(pState) ? pState->Clone() : pState;
             bVisible = true;
         }
commit a8b6ffa99d48f12a63ee6259c2ef2836c3fdaba8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:38:14 2015 +0100

    sfx2: PVS-Studio V595 'pDispatcher' pointer could be null
    
    ... but actually not.
    
    Change-Id: Ia80b416875442dd257ab31f1426b06cc05ffa5c3

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 7aa2e8e..9b22f4e 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -795,9 +795,7 @@ void SfxBindings::InvalidateShell
     // important so that is set correctly: pimp-> ball(Msg)Dirty
     pDispatcher->Flush();
 
-    if ( !pDispatcher ||
-         ( pImp->bAllDirty && pImp->bAllMsgDirty ) ||
-         SfxGetpApp()->IsDowning() )
+    if ((pImp->bAllDirty && pImp->bAllMsgDirty) || SfxGetpApp()->IsDowning())
     {
         // if the next one is anyway, then all the servers are collected
         return;
@@ -1328,9 +1326,10 @@ SfxItemSet* SfxBindings::CreateSet_Impl
     DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
 
     DBG_ASSERT( !pImp->bMsgDirty, "CreateSet_Impl with dirty MessageServer" );
+    assert(pDispatcher);
 
     const SfxSlotServer* pMsgSvr = pCache->GetSlotServer(*pDispatcher, pImp->xProv);
-    if(!pMsgSvr || !pDispatcher)
+    if (!pMsgSvr)
         return 0;
 
     pRealSlot = 0;
commit 7a201ad4bc701a0e535b230a1613b76207f5a4ea
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:32:04 2015 +0100

    sfx2: PVS-Studio V595 'm_pResMgr' pointer could be null
    
    Change-Id: I0701631c928f198e4bb0884c78b3586402a6fcd6

diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index d4ef0bb..5405efb 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -324,7 +324,7 @@ OUString ShutdownIcon::GetResString( int id )
         m_pResMgr = SfxResId::GetResMgr();
     ResId aResId( id, *m_pResMgr );
     aResId.SetRT( RSC_STRING );
-    if( !m_pResMgr || !m_pResMgr->IsAvailable( aResId ) )
+    if (!m_pResMgr->IsAvailable(aResId))
         return OUString();
 
     return ResId(id, *m_pResMgr).toString();
commit 404e4c37f16d1788a615d58bba9ed3929c1e554f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:26:26 2015 +0100

    vcl: PVS-Studio V595 'mpImplWin' pointer could be null
    
    ... but actually it's not if mpFloatWin isn't.
    
    Change-Id: If26444e94221efb9921e94496905834b3ace7d28

diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 9c6f990..3669e18 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1465,6 +1465,7 @@ void ListBox::SetEdgeBlending(bool bNew)
 
         if(IsDropDownBox())
         {
+            assert(mpImplWin);
             mpImplWin->Invalidate();
         }
         else
commit 8fc7b35fb6b2782117d045ffc0142eb5a554ca3e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 19:22:12 2015 +0100

    vcl: spurious PVS-Studio V595
    
    Change-Id: Ia51995fe16d17d16bfc5ffdcbd1636e5c3f2db7a

diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index d051bea..553baa4 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -325,14 +325,11 @@ void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
             // when the frame is reactivated later
             //GrabFocus();
             pActivePopup->ImplExecute( this, Rectangle( aItemTopLeft, aItemBottomRight ), FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_NOHORZPLACEMENT, pMenu, bPreSelectFirst );
-            if ( pActivePopup )
-            {
-                // does not have a window, if aborted before or if there are no entries
-                if ( pActivePopup->ImplGetFloatingWindow() )
-                    pActivePopup->ImplGetFloatingWindow()->AddPopupModeWindow( this );
-                else
-                    pActivePopup = NULL;
-            }
+            // does not have a window, if aborted before or if there are no entries
+            if ( pActivePopup->ImplGetFloatingWindow() )
+                pActivePopup->ImplGetFloatingWindow()->AddPopupModeWindow( this );
+            else
+                pActivePopup = nullptr;
         }
     }
 }
commit ad62a2e1bd8644bff714513e7daf018bf755d306
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:38:07 2015 +0100

    package: PVS-Studio V595 'm_pData' pointer could be null
    
    ... so convert the last member of StorInternalData_Impl that needs
    manual cleanup to rtl::Reference
    
    Change-Id: Ie1549c1f52d50dc3c63715176c02821b63c7cab1

diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 5ad8555..5eac916 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -75,7 +75,7 @@ struct StorInternalData_Impl
     sal_Int32 m_nStorageType; // the mode in which the storage is used
     bool m_bReadOnlyWrap;
 
-    OChildDispListener_Impl* m_pSubElDispListener;
+    ::rtl::Reference<OChildDispListener_Impl> m_pSubElDispListener;
 
     WeakComponentList m_aOpenSubComponentsList;
 
@@ -89,7 +89,7 @@ struct StorInternalData_Impl
     , m_bIsRoot( bRoot )
     , m_nStorageType( nStorageType )
     , m_bReadOnlyWrap( bReadOnlyWrap )
-    , m_pSubElDispListener( NULL )
+    , m_pSubElDispListener()
     {}
 
     ~StorInternalData_Impl();
@@ -1917,28 +1917,17 @@ OStorage::OStorage( OStorage_Impl* pImpl, bool bReadOnlyWrap )
 
 OStorage::~OStorage()
 {
+    ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+    if ( m_pImpl )
     {
-        ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
-        if ( m_pImpl )
-        {
-            m_refCount++; // to call dispose
-            try {
-                dispose();
-            }
-            catch( const uno::RuntimeException& rRuntimeException )
-            {
-                m_pImpl->AddLog( rRuntimeException.Message );
-                m_pImpl->AddLog( THROW_WHERE "Handled exception" );
-            }
+        m_refCount++; // to call dispose
+        try {
+            dispose();
         }
-    }
-
-    if ( m_pData )
-    {
-        if ( m_pData->m_pSubElDispListener )
+        catch( const uno::RuntimeException& rRuntimeException )
         {
-            m_pData->m_pSubElDispListener->release();
-            m_pData->m_pSubElDispListener = NULL;
+            m_pImpl->AddLog( rRuntimeException.Message );
+            m_pImpl->AddLog( THROW_WHERE "Handled exception" );
         }
     }
 }
@@ -1959,10 +1948,10 @@ void SAL_CALL OStorage::InternalDispose( bool bNotifyImpl )
 
     if ( m_pData->m_bReadOnlyWrap )
     {
-        OSL_ENSURE( !m_pData->m_aOpenSubComponentsList.size() || m_pData->m_pSubElDispListener,
+        OSL_ENSURE( !m_pData->m_aOpenSubComponentsList.size() || m_pData->m_pSubElDispListener.get(),
                     "If any subelements are open the listener must exist!\n" );
 
-        if ( m_pData->m_pSubElDispListener )
+        if (m_pData->m_pSubElDispListener.get())
         {
             m_pData->m_pSubElDispListener->OwnerIsDisposed();
 
@@ -1977,7 +1966,7 @@ void SAL_CALL OStorage::InternalDispose( bool bNotifyImpl )
                     if ( xTmp.is() )
                     {
                         xTmp->removeEventListener( uno::Reference< lang::XEventListener >(
-                                    static_cast< lang::XEventListener* >( m_pData->m_pSubElDispListener ) ) );
+                            static_cast< lang::XEventListener* >( m_pData->m_pSubElDispListener.get())));
 
                         try {
                             xTmp->dispose();
@@ -2162,14 +2151,13 @@ void OStorage::MakeLinkToSubComponent_Impl( const uno::Reference< lang::XCompone
     if ( !xComponent.is() )
         throw uno::RuntimeException( THROW_WHERE );
 
-    if ( !m_pData->m_pSubElDispListener )
+    if (!m_pData->m_pSubElDispListener.get())
     {
         m_pData->m_pSubElDispListener = new OChildDispListener_Impl( *this );
-        m_pData->m_pSubElDispListener->acquire();
     }
 
     xComponent->addEventListener( uno::Reference< lang::XEventListener >(
-        static_cast< ::cppu::OWeakObject* >( m_pData->m_pSubElDispListener ), uno::UNO_QUERY ) );
+        static_cast< ::cppu::OWeakObject* >(m_pData->m_pSubElDispListener.get()), uno::UNO_QUERY));
 
     m_pData->m_aOpenSubComponentsList.push_back( xComponent );
 }
commit 44177f020961c2dfdd81498881ee042ba1f30967
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:32:15 2015 +0100

    package: convert StorInternalData_Impl member to std::unique_ptr
    
    Change-Id: If523dbd4596f4023bda6509c6dc09b8ab3d74874

diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 80dc555..5ad8555 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -70,7 +70,7 @@ struct StorInternalData_Impl
 {
     SotMutexHolderRef m_rSharedMutexRef;
     ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
-    ::cppu::OTypeCollection* m_pTypeCollection;
+    ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection;
     bool m_bIsRoot;
     sal_Int32 m_nStorageType; // the mode in which the storage is used
     bool m_bReadOnlyWrap;
@@ -85,7 +85,7 @@ struct StorInternalData_Impl
     StorInternalData_Impl( const SotMutexHolderRef& rMutexRef, bool bRoot, sal_Int32 nStorageType, bool bReadOnlyWrap )
     : m_rSharedMutexRef( rMutexRef )
     , m_aListenersContainer( rMutexRef->GetMutex() )
-    , m_pTypeCollection( NULL )
+    , m_pTypeCollection()
     , m_bIsRoot( bRoot )
     , m_nStorageType( nStorageType )
     , m_bReadOnlyWrap( bReadOnlyWrap )
@@ -160,8 +160,6 @@ uno::Reference< io::XInputStream > GetSeekableTempCopy( uno::Reference< io::XInp
 
 StorInternalData_Impl::~StorInternalData_Impl()
 {
-    if ( m_pTypeCollection )
-        delete m_pTypeCollection;
 }
 
 SotElement_Impl::SotElement_Impl( const OUString& rName, bool bStor, bool bNew )
@@ -1942,12 +1940,6 @@ OStorage::~OStorage()
             m_pData->m_pSubElDispListener->release();
             m_pData->m_pSubElDispListener = NULL;
         }
-
-        if ( m_pData->m_pTypeCollection )
-        {
-            delete m_pData->m_pTypeCollection;
-            m_pData->m_pTypeCollection = NULL;
-        }
     }
 }
 
@@ -2260,17 +2252,17 @@ void SAL_CALL OStorage::release() throw()
 uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
         throw( uno::RuntimeException, std::exception )
 {
-    if ( m_pData->m_pTypeCollection == NULL )
+    if (! m_pData->m_pTypeCollection)
     {
         ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
 
-        if ( m_pData->m_pTypeCollection == NULL )
+        if (! m_pData->m_pTypeCollection)
         {
             if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
             {
                 if ( m_pData->m_bIsRoot )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<embed::XStorage>::get()
                                     ,   cppu::UnoType<embed::XStorage2>::get()
@@ -2281,11 +2273,11 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
                                     ,   cppu::UnoType<embed::XEncryptionProtectedStorage>::get()
                                     ,   cppu::UnoType<embed::XEncryptionProtectedSource2>::get()
                                     ,   cppu::UnoType<embed::XEncryptionProtectedSource>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
                 else
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<embed::XStorage>::get()
                                     ,   cppu::UnoType<embed::XStorage2>::get()
@@ -2293,29 +2285,29 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
                                     ,   cppu::UnoType<embed::XTransactedObject>::get()
                                     ,   cppu::UnoType<embed::XTransactionBroadcaster>::get()
                                     ,   cppu::UnoType<util::XModifiable>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
             }
             else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
             {
-                m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                 (   cppu::UnoType<lang::XTypeProvider>::get()
                                 ,   cppu::UnoType<embed::XStorage>::get()
                                 ,   cppu::UnoType<embed::XTransactedObject>::get()
                                 ,   cppu::UnoType<embed::XTransactionBroadcaster>::get()
                                 ,   cppu::UnoType<util::XModifiable>::get()
                                 ,   cppu::UnoType<embed::XRelationshipAccess>::get()
-                                ,   cppu::UnoType<beans::XPropertySet>::get());
+                                ,   cppu::UnoType<beans::XPropertySet>::get()));
             }
             else
             {
-                m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                 (   cppu::UnoType<lang::XTypeProvider>::get()
                                 ,   cppu::UnoType<embed::XStorage>::get()
                                 ,   cppu::UnoType<embed::XTransactedObject>::get()
                                 ,   cppu::UnoType<embed::XTransactionBroadcaster>::get()
                                 ,   cppu::UnoType<util::XModifiable>::get()
-                                ,   cppu::UnoType<beans::XPropertySet>::get());
+                                ,   cppu::UnoType<beans::XPropertySet>::get()));
             }
         }
     }
commit c3e45f10e003e540710c18967ef9b29210a795e4
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:29:02 2015 +0100

    package: convert OStorage::m_pData to std::unique_ptr
    
    Change-Id: I875432aeb98072882df1f228d9fcf43c6027e8d5

diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 254c2b2..80dc555 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -1887,7 +1887,7 @@ OStorage::OStorage( uno::Reference< io::XInputStream > xInputStream,
 : m_pImpl( new OStorage_Impl( xInputStream, nMode, xProperties, xContext, nStorageType ) )
 {
     m_pImpl->m_pAntiImpl = this;
-    m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, false );
+    m_pData.reset(new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, false));
 }
 
 OStorage::OStorage( uno::Reference< io::XStream > xStream,
@@ -1898,7 +1898,7 @@ OStorage::OStorage( uno::Reference< io::XStream > xStream,
 : m_pImpl( new OStorage_Impl( xStream, nMode, xProperties, xContext, nStorageType ) )
 {
     m_pImpl->m_pAntiImpl = this;
-    m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, false );
+    m_pData.reset(new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, false));
 }
 
 OStorage::OStorage( OStorage_Impl* pImpl, bool bReadOnlyWrap )
@@ -1907,7 +1907,7 @@ OStorage::OStorage( OStorage_Impl* pImpl, bool bReadOnlyWrap )
     // this call can be done only from OStorage_Impl implementation to create child storage
     OSL_ENSURE( m_pImpl && m_pImpl->m_rMutexRef.Is(), "The provided pointer & mutex MUST NOT be empty!\n" );
 
-    m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, bReadOnlyWrap );
+    m_pData.reset(new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, bReadOnlyWrap));
 
     OSL_ENSURE( ( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) == embed::ElementModes::WRITE ||
                     m_pData->m_bReadOnlyWrap,
@@ -1948,8 +1948,6 @@ OStorage::~OStorage()
             delete m_pData->m_pTypeCollection;
             m_pData->m_pTypeCollection = NULL;
         }
-
-        delete m_pData;
     }
 }
 
diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx
index d15b39b..c8688ec 100644
--- a/package/source/xstor/xstorage.hxx
+++ b/package/source/xstor/xstorage.hxx
@@ -51,6 +51,7 @@
 #include "mutexholder.hxx"
 
 #include <list>
+#include <memory>
 
 namespace com { namespace sun { namespace star { namespace uno {
     class XComponentContext;
@@ -293,7 +294,7 @@ class OStorage  : public ::com::sun::star::lang::XTypeProvider
                 , public ::cppu::OWeakObject
 {
     OStorage_Impl*  m_pImpl;
-    StorInternalData_Impl* m_pData;
+    std::unique_ptr<StorInternalData_Impl> m_pData;
 
 protected:
 
commit e43d5f26de3c5a366bdb3c5ed83d30e725870855
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:23:18 2015 +0100

    package: move WSInternalData_Impl out of header
    
    Change-Id: Ie7c01b37e9a4eb2221d4b40fc6b13672d9b3a684

diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 38e6563..b64e76f 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -55,6 +55,22 @@
 
 using namespace ::com::sun::star;
 
+struct WSInternalData_Impl
+{
+    SotMutexHolderRef m_rSharedMutexRef;
+    ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection;
+    ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
+    sal_Int32 m_nStorageType;
+
+    // the mutex reference MUST NOT be empty
+    WSInternalData_Impl( const SotMutexHolderRef& rMutexRef, sal_Int32 nStorageType )
+    : m_rSharedMutexRef( rMutexRef )
+    , m_pTypeCollection()
+    , m_aListenersContainer( rMutexRef->GetMutex() )
+    , m_nStorageType( nStorageType )
+    {}
+};
+
 namespace package
 {
 
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index ad6ddf2..2a5b1cf 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -43,7 +43,6 @@
 #include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/interfacecontainer.h>
-#include <cppuhelper/typeprovider.hxx>
 
 #include <comphelper/sequenceashashmap.hxx>
 
@@ -71,21 +70,7 @@ namespace package {
     bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 );
 }
 
-struct WSInternalData_Impl
-{
-    SotMutexHolderRef m_rSharedMutexRef;
-    ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection;
-    ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
-    sal_Int32 m_nStorageType;
-
-    // the mutex reference MUST NOT be empty
-    WSInternalData_Impl( const SotMutexHolderRef& rMutexRef, sal_Int32 nStorageType )
-    : m_rSharedMutexRef( rMutexRef )
-    , m_pTypeCollection()
-    , m_aListenersContainer( rMutexRef->GetMutex() )
-    , m_nStorageType( nStorageType )
-    {}
-};
+struct WSInternalData_Impl;
 
 typedef ::std::list< OInputCompStream* > InputStreamsList_Impl;
 
commit 9ad17c2536468b37c04bc7f7b74dd794d1dc38c7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:20:10 2015 +0100

    package: convert OWriteStream::m_pData to std::unique_ptr
    
    Change-Id: I9e72325679b2758cd4297d2693cf49fd533f8baa

diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index cf20db3..38e6563 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -1683,7 +1683,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, bool bTransacted )
     if ( !m_pImpl || !m_pImpl->m_rMutexRef.Is() )
         throw uno::RuntimeException(); // just a disaster
 
-    m_pData = new WSInternalData_Impl( pImpl->m_rMutexRef, m_pImpl->m_nStorageType );
+    m_pData.reset(new WSInternalData_Impl(pImpl->m_rMutexRef, m_pImpl->m_nStorageType));
 }
 
 OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStream > xStream, bool bTransacted )
@@ -1699,7 +1699,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea
     if ( !m_pImpl || !m_pImpl->m_rMutexRef.Is() )
         throw uno::RuntimeException(); // just a disaster
 
-    m_pData = new WSInternalData_Impl( pImpl->m_rMutexRef, m_pImpl->m_nStorageType );
+    m_pData.reset(new WSInternalData_Impl(pImpl->m_rMutexRef, m_pImpl->m_nStorageType));
 
     if ( xStream.is() )
     {
@@ -1712,23 +1712,19 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea
 
 OWriteStream::~OWriteStream()
 {
+    ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+    if ( m_pImpl )
     {
-        ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
-        if ( m_pImpl )
+        m_refCount++;
+        try {
+            dispose();
+        }
+        catch( const uno::RuntimeException& rRuntimeException )
         {
-            m_refCount++;
-            try {
-                dispose();
-            }
-            catch( const uno::RuntimeException& rRuntimeException )
-            {
-                m_pImpl->AddLog( rRuntimeException.Message );
-                m_pImpl->AddLog( "Quiet exception" );
-            }
+            m_pImpl->AddLog( rRuntimeException.Message );
+            m_pImpl->AddLog( "Quiet exception" );
         }
     }
-
-    delete m_pData;
 }
 
 void OWriteStream::DeInit()
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index 066d880..ad6ddf2 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -276,7 +276,7 @@ protected:
     ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
 
     OWriteStream_Impl* m_pImpl;
-    WSInternalData_Impl* m_pData;
+    std::unique_ptr<WSInternalData_Impl> m_pData;
 
     bool m_bInStreamDisconnected;
     bool m_bInitOnDemand;
commit 2877e5a9c7507acc9282e70323259b5c043dda0c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 18:16:57 2015 +0100

    package: PVS-Studio V595 'm_pData' pointer could be null
    
    ... just convert its explicitly deleted member to unique_ptr.
    
    Change-Id: I826257ff512632a2aedd53a7ce5e4bedf49c3cfe

diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 31a99df..cf20db3 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -1728,9 +1728,6 @@ OWriteStream::~OWriteStream()
         }
     }
 
-    if ( m_pData && m_pData->m_pTypeCollection )
-        delete m_pData->m_pTypeCollection;
-
     delete m_pData;
 }
 
@@ -1922,11 +1919,11 @@ void SAL_CALL OWriteStream::release() throw()
 uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
         throw( uno::RuntimeException, std::exception )
 {
-    if ( m_pData->m_pTypeCollection == NULL )
+    if (! m_pData->m_pTypeCollection)
     {
         ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
 
-        if ( m_pData->m_pTypeCollection == NULL )
+        if (! m_pData->m_pTypeCollection)
         {
             if ( m_bTransacted )
             {
@@ -1946,13 +1943,13 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<embed::XTransactedObject>::get()
                                     ,   cppu::UnoType<embed::XTransactionBroadcaster>::get());
 
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<beans::XPropertySet>::get()
-                                    ,   aTmpCollection.getTypes() );
+                                    ,   aTmpCollection.getTypes()));
                 }
                 else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<io::XInputStream>::get()
                                     ,   cppu::UnoType<io::XOutputStream>::get()
@@ -1964,11 +1961,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<embed::XExtendedStorageStream>::get()
                                     ,   cppu::UnoType<embed::XTransactedObject>::get()
                                     ,   cppu::UnoType<embed::XTransactionBroadcaster>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
                 else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<io::XInputStream>::get()
                                     ,   cppu::UnoType<io::XOutputStream>::get()
@@ -1979,14 +1976,14 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<embed::XExtendedStorageStream>::get()
                                     ,   cppu::UnoType<embed::XTransactedObject>::get()
                                     ,   cppu::UnoType<embed::XTransactionBroadcaster>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
             }
             else
             {
                 if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<io::XInputStream>::get()
                                     ,   cppu::UnoType<io::XOutputStream>::get()
@@ -1996,11 +1993,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<lang::XComponent>::get()
                                     ,   cppu::UnoType<embed::XEncryptionProtectedSource2>::get()
                                     ,   cppu::UnoType<embed::XEncryptionProtectedSource>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
                 else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<io::XInputStream>::get()
                                     ,   cppu::UnoType<io::XOutputStream>::get()
@@ -2009,11 +2006,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<io::XTruncate>::get()
                                     ,   cppu::UnoType<lang::XComponent>::get()
                                     ,   cppu::UnoType<embed::XRelationshipAccess>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
                 else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
                 {
-                    m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+                    m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
                                     (   cppu::UnoType<lang::XTypeProvider>::get()
                                     ,   cppu::UnoType<io::XInputStream>::get()
                                     ,   cppu::UnoType<io::XOutputStream>::get()
@@ -2021,7 +2018,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
                                     ,   cppu::UnoType<io::XSeekable>::get()
                                     ,   cppu::UnoType<io::XTruncate>::get()
                                     ,   cppu::UnoType<lang::XComponent>::get()
-                                    ,   cppu::UnoType<beans::XPropertySet>::get());
+                                    ,   cppu::UnoType<beans::XPropertySet>::get()));
                 }
             }
         }
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index 69b4f91..066d880 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -43,10 +43,12 @@
 #include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/typeprovider.hxx>
 
 #include <comphelper/sequenceashashmap.hxx>
 
 #include <list>
+#include <memory>
 
 #include "ocompinstream.hxx"
 #include "mutexholder.hxx"
@@ -65,10 +67,6 @@ struct PreCreationStruct
 
 };
 
-namespace cppu {
-    class OTypeCollection;
-}
-
 namespace package {
     bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 );
 }
@@ -76,14 +74,14 @@ namespace package {
 struct WSInternalData_Impl
 {
     SotMutexHolderRef m_rSharedMutexRef;
-    ::cppu::OTypeCollection* m_pTypeCollection;
+    ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection;
     ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
     sal_Int32 m_nStorageType;
 
     // the mutex reference MUST NOT be empty
     WSInternalData_Impl( const SotMutexHolderRef& rMutexRef, sal_Int32 nStorageType )
     : m_rSharedMutexRef( rMutexRef )
-    , m_pTypeCollection( NULL )
+    , m_pTypeCollection()
     , m_aListenersContainer( rMutexRef->GetMutex() )
     , m_nStorageType( nStorageType )
     {}
commit cd347b3b34343d696a3c90352ff91eb64a1057b0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 12 17:49:24 2015 +0100

    sw: suppress spurious PVS-Studio V509
    
    Change-Id: If70877bf7d56e3047951a26db8efbfb8e8c22ce3

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 5d22508..2efece0 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -842,7 +842,10 @@ namespace sw { namespace mark
         { }
         virtual ~LazyFieldmarkDeleter()
         {
-            dynamic_cast<Fieldmark&>(*m_pFieldmark.get()).ReleaseDoc(m_pDoc);
+            Fieldmark *const pFieldMark(
+                    dynamic_cast<Fieldmark*>(m_pFieldmark.get()));
+            assert(pFieldMark);
+            pFieldMark->ReleaseDoc(m_pDoc);
         }
     };
 


More information about the Libreoffice-commits mailing list