[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - accessibility/source

Michael Stahl mstahl at redhat.com
Mon Oct 7 01:38:32 PDT 2013


 accessibility/source/extended/AccessibleGridControl.cxx |   33 ++++++++++++----
 1 file changed, 25 insertions(+), 8 deletions(-)

New commits:
commit c7d046755cfb3f17043dee41f5060c2bfa1fd40f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Oct 3 23:16:34 2013 +0200

    fix STL assert in accessibility::AccessibleGridControl::commitTableEvent
    
    While running some JunitTest, crashes on an attempt to delete entries
    of an empty vector m_pImpl->m_pTable->m_pCellVector.
    
    The entries are created on-demand by
    AccessibleGridControlTable::getAccessibleChild(), so presumably that
    hadn't been called yet when the rows were deleted.
    
    Also fix bizarre abuse of all applicable variable naming conventions.
    
    (regression from 2095b2e1d44a158418d17836019352ed92f95d21)
    
    Change-Id: Id2d70ca4601a166718629c0fe922f805dd72eec1
    (cherry picked from commit 4fc7deb7b0528010ebf644654bf4a36594e03f8c)
    Reviewed-on: https://gerrit.libreoffice.org/6131
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx
index ace45d2..fac2054 100644
--- a/accessibility/source/extended/AccessibleGridControl.cxx
+++ b/accessibility/source/extended/AccessibleGridControl.cxx
@@ -337,11 +337,13 @@ void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNew
             com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext > xAccessibleChild = xAccessible->getAccessibleContext();
             if(m_pImpl->m_xTable == xAccessible)
             {
-                std::vector< AccessibleGridControlTableCell* > xCellCont = m_pImpl->m_pTable->getCellVector();
-                int nIndex = m_aTable.GetCurrentRow()*m_aTable.GetColumnCount()+m_aTable.GetCurrentColumn();
-                if(!xCellCont.empty() && xCellCont[nIndex])
+                std::vector< AccessibleGridControlTableCell* >& rCells =
+                    m_pImpl->m_pTable->getCellVector();
+                size_t nIndex = m_aTable.GetCurrentRow() * m_aTable.GetColumnCount()
+                              + m_aTable.GetCurrentColumn();
+                if (nIndex < rCells.size() && rCells[nIndex])
                 {
-                    m_pImpl->m_pCell = xCellCont[nIndex];
+                    m_pImpl->m_pCell = rCells[nIndex];
                     m_pImpl->m_pCell->commitEvent( _nEventId, _rNewValue, _rOldValue );
                 }
             }
@@ -370,11 +372,26 @@ void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNe
             {
                 if(aChange.Type == AccessibleTableModelChangeType::DELETE)
                 {
-                    std::vector< AccessibleGridControlTableCell* >::iterator m_pCell = m_pImpl->m_pTable->getCellVector().begin();
-                    std::vector< Reference< XAccessible > >::iterator m_xAccessibleVector = m_pImpl->m_pTable->getAccessibleCellVector().begin();
+                    std::vector< AccessibleGridControlTableCell* >& rCells =
+                        m_pImpl->m_pTable->getCellVector();
+                    std::vector< Reference< XAccessible > >& rAccCells =
+                        m_pImpl->m_pTable->getAccessibleCellVector();
                     int nColCount = m_aTable.GetColumnCount();
-                    m_pImpl->m_pTable->getCellVector().erase(m_pCell+nColCount*aChange.FirstRow, m_pCell+nColCount*aChange.LastRow );
-                    m_pImpl->m_pTable->getAccessibleCellVector().erase(m_xAccessibleVector+nColCount*aChange.FirstRow, m_xAccessibleVector+nColCount*aChange.LastRow);
+                    // check valid index - entries are inserted lazily
+                    size_t const nStart = nColCount * aChange.FirstRow;
+                    size_t const nEnd   = nColCount * aChange.LastRow;
+                    if (nStart < rCells.size())
+                    {
+                        m_pImpl->m_pTable->getCellVector().erase(
+                            rCells.begin() + nStart,
+                            rCells.begin() + std::min(rCells.size(), nEnd));
+                    }
+                    if (nStart < rAccCells.size())
+                    {
+                        m_pImpl->m_pTable->getAccessibleCellVector().erase(
+                            rAccCells.begin() + nStart,
+                            rAccCells.begin() + std::min(rAccCells.size(), nEnd));
+                    }
                     m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
                 }
                 else


More information about the Libreoffice-commits mailing list