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

Ashod Nakashian ashodnakashian at yahoo.com
Wed Jan 21 08:38:59 PST 2015


 sw/inc/ndhints.hxx                 |   24 ++++++++++++++++++------
 sw/source/core/txtnode/ndhints.cxx |    4 ++++
 2 files changed, 22 insertions(+), 6 deletions(-)

New commits:
commit 4fcde4fe8ea5d4521a59e19291e393835144d7d9
Author: Ashod Nakashian <ashodnakashian at yahoo.com>
Date:   Fri Jan 9 11:08:58 2015 -0500

    Hint assertions and sanity checks added.
    
    Change-Id: I83bf8866c8855b3266703eca62010d28388c5a07
    Reviewed-on: https://gerrit.libreoffice.org/13880
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 4bfbd1f..1202b7b 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -103,13 +103,25 @@ public:
     SwTxtAttr * Cut( const size_t nPosInStart );
 
     inline const SwTxtAttr * GetStart( const size_t nPos ) const
-        { return m_HintStarts[nPos]; }
+    {
+        assert(nPos < m_HintStarts.size());
+        return m_HintStarts[nPos];
+    }
     inline const SwTxtAttr * GetEnd( const size_t nPos ) const
-        { return m_HintEnds  [nPos]; }
+    {
+        assert(nPos < m_HintEnds.size());
+        return m_HintEnds[nPos];
+    }
     inline       SwTxtAttr * GetStart( const size_t nPos )
-        { return m_HintStarts[nPos]; }
+    {
+        assert(nPos < m_HintStarts.size());
+        return m_HintStarts[nPos];
+    }
     inline       SwTxtAttr * GetEnd( const size_t nPos )
-        { return m_HintEnds  [nPos]; }
+    {
+        assert(nPos < m_HintStarts.size());
+        return m_HintEnds[nPos];
+    }
 
     inline size_t GetEndCount()   const { return m_HintEnds.size(); }
     inline size_t GetStartCount() const { return m_HintStarts.size(); }
@@ -122,8 +134,8 @@ public:
     inline       SwTxtAttr * GetTextHint( const size_t nIdx )
         { return GetStart(nIdx); }
     inline const SwTxtAttr * operator[]( const size_t nIdx ) const
-        { return m_HintStarts[nIdx]; }
-    inline size_t Count() const { return m_HintStarts.size(); }
+        { return GetStart(nIdx); }
+    inline size_t Count() const { return GetStartCount(); }
 
 #ifdef DBG_UTIL
     bool Check(bool) const;
diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx
index 5f1d84c..3808008 100644
--- a/sw/source/core/txtnode/ndhints.cxx
+++ b/sw/source/core/txtnode/ndhints.cxx
@@ -132,6 +132,10 @@ void SwpHintsArray::DeleteAtPos( const size_t nPos )
 
 bool SwpHintsArray::Contains( const SwTxtAttr *pHt ) const
 {
+#ifdef DBG_UTIL
+    Check(true);
+#endif
+
     // DO NOT use find() here!
     // if called from SwTxtNode::InsertItem, pHt has already been deleted,
     // so it cannot be dereferenced


More information about the Libreoffice-commits mailing list