[Libreoffice-commits] core.git: 4 commits - include/sfx2 sc/source sfx2/source

Caolán McNamara caolanm at redhat.com
Thu May 29 03:03:11 PDT 2014


 include/sfx2/sfxbasemodel.hxx      |   77 -------------------------------------
 include/sfx2/unoctitm.hxx          |    3 -
 sc/source/core/data/column3.cxx    |   23 ++++++-----
 sfx2/source/control/unoctitm.cxx   |    3 -
 sfx2/source/doc/docundomanager.cxx |   13 ++----
 sfx2/source/inc/docundomanager.hxx |   77 +++++++++++++++++++++++++++++++++++--
 6 files changed, 97 insertions(+), 99 deletions(-)

New commits:
commit a35d92197d850527bd294eb6197b5bf83109d5be
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 29 10:45:39 2014 +0100

    Resolves: fdo#79392 don't access after last row, when last row is max last row
    
    Change-Id: I06749af90bed6a43f3fb6b3b5ceb61d5fbbc7c02

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index d023b16..aa84d8d 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -182,19 +182,22 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 
     // Check if there are any cells below the end row that will get shifted.
     bool bShiftCells = false;
-    aPos = maCells.position(itCell, nEndRow+1);
-    itCell = aPos.first;
-    if (itCell->type == sc::element_type_empty)
+    if (nEndRow < MAXROWCOUNT-1) //only makes sense to do this if there *is* a row after the end row
     {
-        // This block is empty. See if there is any block that follows.
-        sc::CellStoreType::iterator itTest = itCell;
-        ++itTest;
-        if (itTest != maCells.end())
-            // Non-empty block follows -> cells that will get shifted.
+        aPos = maCells.position(itCell, nEndRow+1);
+        itCell = aPos.first;
+        if (itCell->type == sc::element_type_empty)
+        {
+            // This block is empty. See if there is any block that follows.
+            sc::CellStoreType::iterator itTest = itCell;
+            ++itTest;
+            if (itTest != maCells.end())
+                // Non-empty block follows -> cells that will get shifted.
+                bShiftCells = true;
+        }
+        else
             bShiftCells = true;
     }
-    else
-        bShiftCells = true;
 
     sc::SingleColumnSpanSet aNonEmptySpans;
     if (bShiftCells)
commit da6df38b4193d03143172d73006adf34b3271f7b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 29 10:46:12 2014 +0100

    Related: fdo#79392 std::out_or_range -> terminate
    
    Change-Id: I0aada90e9ea4e9fc92fd9c365aa9c7171cb10a55

diff --git a/include/sfx2/unoctitm.hxx b/include/sfx2/unoctitm.hxx
index 6e8d572..97d12da 100644
--- a/include/sfx2/unoctitm.hxx
+++ b/include/sfx2/unoctitm.hxx
@@ -169,7 +169,8 @@ public:
     void                setMasterSlaveCommand( bool bSet );
     void SAL_CALL       dispatch( const ::com::sun::star::util::URL& aURL,
                                   const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs,
-                                  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener ) throw( ::com::sun::star::uno::RuntimeException );
+                                  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener )
+        throw (css::uno::RuntimeException, std::exception);
     void SAL_CALL       addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
     void                UnBindController();
     SfxDispatcher*      GetDispatcher();
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index de2dff0..400063f 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -593,7 +593,8 @@ OUString SfxDispatchController_Impl::getSlaveCommand( const ::com::sun::star::ut
 
 void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util::URL& aURL,
         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener ) throw( ::com::sun::star::uno::RuntimeException )
+        const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener )
+    throw (css::uno::RuntimeException, std::exception)
 {
     SolarMutexGuard aGuard;
     if (
commit c24272c7972e0cbb51e7f104e356973ecb03c352
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 29 09:58:42 2014 +0100

    the dubious SfxModelSubComponent and friends aren't used outside sfx2
    
    so move out of the globals headers and drop their public visibility
    markup
    
    Change-Id: Ie0a852c962a9d05488022397e83152d1c73cfa29

diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx
index 9988183..25c5a09 100644
--- a/include/sfx2/sfxbasemodel.hxx
+++ b/include/sfx2/sfxbasemodel.hxx
@@ -894,82 +894,6 @@ private:
 
 } ; // class SfxBaseModel
 
-/** base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the SfxBaseModel
-*/
-class SFX2_DLLPUBLIC SfxModelSubComponent
-{
-public:
-    /** checks whether the instance is alive, i.e. properly initialized, and not yet disposed
-    */
-    void    MethodEntryCheck()
-    {
-        m_rModel.MethodEntryCheck( true );
-    }
-
-    // called when the SfxBaseModel which the component is superordinate of is being disposed
-    virtual void disposing();
-
-protected:
-    SfxModelSubComponent( SfxBaseModel& i_model )
-        :m_rModel( i_model )
-    {
-    }
-    virtual ~SfxModelSubComponent();
-
-    void acquireModel()  { m_rModel.acquire(); }
-    void releaseModel()  { m_rModel.release(); }
-
-    bool isDisposed() const {   return m_rModel.IsDisposed();   }
-
-protected:
-    const SfxBaseModel& getBaseModel() const { return m_rModel; }
-          SfxBaseModel& getBaseModel()       { return m_rModel; }
-
-          ::osl::Mutex&  getMutex()          { return m_rModel.getMutex(); }
-
-private:
-    SfxBaseModel&   m_rModel;
-};
-
-class SFX2_DLLPUBLIC SfxModelGuard
-{
-public:
-    enum AllowedModelState
-    {
-        // not yet initialized
-        E_INITIALIZING,
-        // fully alive, i.e. initialized, and not yet disposed
-        E_FULLY_ALIVE
-    };
-
-    SfxModelGuard( SfxBaseModel& i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE )
-        : m_aGuard()
-    {
-        i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING );
-    }
-    SfxModelGuard( SfxModelSubComponent& i_rSubComponent )
-        :m_aGuard()
-    {
-        i_rSubComponent.MethodEntryCheck();
-    }
-    ~SfxModelGuard()
-    {
-    }
-
-    void reset()
-    {
-        m_aGuard.reset();
-    }
-
-    void clear()
-    {
-        m_aGuard.clear();
-    }
-
-private:
-    SolarMutexResettableGuard  m_aGuard;
-};
-
 #endif // INCLUDED_SFX2_SFXBASEMODEL_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/docundomanager.cxx b/sfx2/source/doc/docundomanager.cxx
index ff87613..b816e51 100644
--- a/sfx2/source/doc/docundomanager.cxx
+++ b/sfx2/source/doc/docundomanager.cxx
@@ -19,7 +19,6 @@
 
 
 #include "docundomanager.hxx"
-#include <cppuhelper/weak.hxx>
 #include <sfx2/sfxbasemodel.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/viewfrm.hxx>
diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx
index 044d0fb..f970bed 100644
--- a/sfx2/source/inc/docundomanager.hxx
+++ b/sfx2/source/inc/docundomanager.hxx
@@ -29,12 +29,84 @@
 #include <boost/scoped_ptr.hpp>
 #include <boost/noncopyable.hpp>
 
+/** base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the SfxBaseModel
+*/
+class SfxModelSubComponent
+{
+public:
+    /** checks whether the instance is alive, i.e. properly initialized, and not yet disposed
+    */
+    void    MethodEntryCheck()
+    {
+        m_rModel.MethodEntryCheck( true );
+    }
 
-namespace sfx2
+    // called when the SfxBaseModel which the component is superordinate of is being disposed
+    virtual void disposing();
+
+protected:
+    SfxModelSubComponent( SfxBaseModel& i_model )
+        :m_rModel( i_model )
+    {
+    }
+    virtual ~SfxModelSubComponent();
+
+    void acquireModel()  { m_rModel.acquire(); }
+    void releaseModel()  { m_rModel.release(); }
+
+    bool isDisposed() const {   return m_rModel.IsDisposed();   }
+
+protected:
+    const SfxBaseModel& getBaseModel() const { return m_rModel; }
+          SfxBaseModel& getBaseModel()       { return m_rModel; }
+
+          ::osl::Mutex&  getMutex()          { return m_rModel.getMutex(); }
+
+private:
+    SfxBaseModel&   m_rModel;
+};
+
+class SfxModelGuard
 {
+public:
+    enum AllowedModelState
+    {
+        // not yet initialized
+        E_INITIALIZING,
+        // fully alive, i.e. initialized, and not yet disposed
+        E_FULLY_ALIVE
+    };
 
+    SfxModelGuard( SfxBaseModel& i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE )
+        : m_aGuard()
+    {
+        i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING );
+    }
+    SfxModelGuard( SfxModelSubComponent& i_rSubComponent )
+        :m_aGuard()
+    {
+        i_rSubComponent.MethodEntryCheck();
+    }
+    ~SfxModelGuard()
+    {
+    }
 
+    void reset()
+    {
+        m_aGuard.reset();
+    }
 
+    void clear()
+    {
+        m_aGuard.clear();
+    }
+
+private:
+    SolarMutexResettableGuard  m_aGuard;
+};
+
+namespace sfx2
+{
     //= DocumentUndoManager
 
     typedef ::cppu::WeakImplHelper1 <css::document::XUndoManager> DocumentUndoManager_Base;
commit a65b6a4626d85880a4f39bda177473df91cf5369
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 29 09:48:13 2014 +0100

    valgrind: memleak when sidebar open in writer on close
    
    ==3768== 512 bytes in 1 blocks are possibly lost in loss record 25,532 of 28,010
    ==3768==    at 0x4A06965: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==3768==    by 0xB52FA41: __gnu_cxx::new_allocator<bool>::allocate(unsigned long, void const*) (new_allocator.h:104)
    ==3768==    by 0xB52EC00: std::__cxx1998::_Deque_base<bool, std::allocator<bool> >::_M_allocate_node() (stl_deque.h:533)
    ==3768==    by 0xB52DE4E: std::__cxx1998::_Deque_base<bool, std::allocator<bool> >::_M_create_nodes(bool**, bool**) (stl_deque.h:627)
    ==3768==    by 0xB52C624: std::__cxx1998::_Deque_base<bool, std::allocator<bool> >::_M_initialize_map(unsigned long) (stl_deque.h:601)
    ==3768==    by 0xB52ACA0: std::__cxx1998::_Deque_base<bool, std::allocator<bool> >::_Deque_base(std::allocator<bool> const&, unsigned long) (stl_deque.h:461)
    ==3768==    by 0xB5296D3: std::__cxx1998::deque<bool, std::allocator<bool> >::deque(std::allocator<bool> const&) (stl_deque.h:791)
    ==3768==    by 0xB52840E: std::__debug::deque<bool, std::allocator<bool> >::deque(std::allocator<bool> const&) (deque:73)
    ==3768==    by 0xB52786B: framework::UndoManagerHelper_Impl::UndoManagerHelper_Impl(framework::IUndoManagerImplementation&) (undomanagerhelper.cxx:221)
    ==3768==    by 0xB525882: framework::UndoManagerHelper::UndoManagerHelper(framework::IUndoManagerImplementation&) (undomanagerhelper.cxx:879)
    ==3768==    by 0x6872683: sfx2::DocumentUndoManager_Impl::DocumentUndoManager_Impl(sfx2::DocumentUndoManager&) (docundomanager.cxx:88)
    ==3768==    by 0x6870FB6: sfx2::DocumentUndoManager::DocumentUndoManager(SfxBaseModel&) (docundomanager.cxx:227)
    ==3768==    by 0x687A272: SfxBaseModel::getUndoManager() (sfxbasemodel.cxx:1677)
    ==3768==    by 0x260E562A: (anonymous namespace)::getUndoManager(com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (PagePropertyPanel.cxx:74)
    ==3768==    by 0x260E6C60: sw::sidebar::PagePropertyPanel::PagePropertyPanel(Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, SfxBindings*) (PagePropertyPanel.cxx:189)
    ==3768==    by 0x260E593C: sw::sidebar::PagePropertyPanel::Create(Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, SfxBindings*) (PagePropertyPanel.cxx:101)
    
    The SfxBaseModel creates the DocumentUndoManager on demand at
    sfx2/source/doc/sfxbasemodel.cxx:1685
    
    m_pDocumentUndoManager is a rtl::Reference but debugging into the
    acquire/release I see that the
    DocumentUndoManager::acquire/DocumentUndoManager::release forward to those of
    SfxModelSubComponent which forward them to its rModel without doing anything
    else, so the implementations of
    DocumentUndoManager::acquire/DocumentUndoManager::release don't actually do
    anything directly to the DocumentUndoManager itself so there is nothing that
    will really release it.
    
    Either the rModel needs to explicitly destroy it somehow, given that the
    acquire/release delegate responsibility to it, or the whole thing is addled.
    
    I rather feel it's addled, so implement as a normal WeakImplHelper1, but
    cowardly in addition also keep acquire/release on the rModel.
    
    Change-Id: Ib52544a9276fd8d9d489ad6b6afda12498cc39fa

diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx
index fd33b2d..9988183 100644
--- a/include/sfx2/sfxbasemodel.hxx
+++ b/include/sfx2/sfxbasemodel.hxx
@@ -916,9 +916,8 @@ protected:
     }
     virtual ~SfxModelSubComponent();
 
-    // helpers for implementing XInterface - delegates ref counting to the SfxBaseModel
-    void acquire()  {   m_rModel.acquire(); }
-    void release()  {   m_rModel.release(); }
+    void acquireModel()  { m_rModel.acquire(); }
+    void releaseModel()  { m_rModel.release(); }
 
     bool isDisposed() const {   return m_rModel.IsDisposed();   }
 
diff --git a/sfx2/source/doc/docundomanager.cxx b/sfx2/source/doc/docundomanager.cxx
index 5ab013c..ff87613 100644
--- a/sfx2/source/doc/docundomanager.cxx
+++ b/sfx2/source/doc/docundomanager.cxx
@@ -19,12 +19,12 @@
 
 
 #include "docundomanager.hxx"
+#include <cppuhelper/weak.hxx>
 #include <sfx2/sfxbasemodel.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/viewsh.hxx>
 #include <sfx2/bindings.hxx>
-
 #include <com/sun/star/lang/XComponent.hpp>
 
 #include <comphelper/anytostring.hxx>
@@ -228,12 +228,10 @@ namespace sfx2
     {
     }
 
-
     DocumentUndoManager::~DocumentUndoManager()
     {
     }
 
-
     void DocumentUndoManager::disposing()
     {
         m_pImpl->disposing();
@@ -247,15 +245,17 @@ namespace sfx2
     }
 
 
-    void SAL_CALL DocumentUndoManager::acquire(  ) throw ()
+    void SAL_CALL DocumentUndoManager::acquire() throw()
     {
-        SfxModelSubComponent::acquire();
+        OWeakObject::acquire();
+        SfxModelSubComponent::acquireModel();
     }
 
 
-    void SAL_CALL DocumentUndoManager::release(  ) throw ()
+    void SAL_CALL DocumentUndoManager::release() throw()
     {
-        SfxModelSubComponent::release();
+        SfxModelSubComponent::releaseModel();
+        OWeakObject::release();
     }
 
 
diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx
index 31d8731..044d0fb 100644
--- a/sfx2/source/inc/docundomanager.hxx
+++ b/sfx2/source/inc/docundomanager.hxx
@@ -37,8 +37,7 @@ namespace sfx2
 
     //= DocumentUndoManager
 
-    typedef ::cppu::ImplHelper1 <   ::com::sun::star::document::XUndoManager
-                                >   DocumentUndoManager_Base;
+    typedef ::cppu::WeakImplHelper1 <css::document::XUndoManager> DocumentUndoManager_Base;
     struct DocumentUndoManager_Impl;
     class DocumentUndoManager   :public DocumentUndoManager_Base
                                 ,public SfxModelSubComponent


More information about the Libreoffice-commits mailing list