diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-05-05 15:23:35 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-05-05 23:51:36 +0200 |
commit | cd83ef996b09907d669d686d1a33db5a8f08f72d (patch) | |
tree | c1fdfd4bb6c89aacb655d22a2ca02004b13f0fd0 | |
parent | ebd4986c3495239f09510f2c0c79b6e30acda83e (diff) |
fdo#57197: sw: check that cells are still alive ...
... before firing events from them; use a thread-safe WeakReference.
(regression from 76c549eb01dcb7b5bf28a271ce00e386f3d388ba)
Change-Id: Ie060d27cc44415e9a75b75027f5510577ac17a6e
-rw-r--r-- | sw/source/core/access/acctable.cxx | 41 | ||||
-rw-r--r-- | sw/source/core/access/acctable.hxx | 9 |
2 files changed, 30 insertions, 20 deletions
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index e798c52c1d12..2bb9fd625a3b 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -1730,26 +1730,33 @@ void SwAccessibleTable::FireSelectionEvent( ) aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; -// int nRemove = m_vecCellRemove.size(); -// int nAdd = m_vecCellAdd.size(); - - VEC_CELL::iterator vi = m_vecCellRemove.begin(); - for (; vi != m_vecCellRemove.end() ; ++vi) + for (Cells_t::iterator vi = m_vecCellRemove.begin(); + vi != m_vecCellRemove.end(); ++vi) { - SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi); - OSL_ASSERT(pAccCell != NULL ); - pAccCell->FireAccessibleEvent(aEvent); + // fdo#57197: check if the object is still alive + uno::Reference<XAccessible> const xAcc(vi->second); + if (xAcc.is()) + { + SwAccessibleContext *const pAccCell(vi->first); + assert(pAccCell); + pAccCell->FireAccessibleEvent(aEvent); + } } if (m_vecCellAdd.size() <= SELECTION_WITH_NUM) { aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; - vi = m_vecCellAdd.begin(); - for (; vi != m_vecCellAdd.end() ; ++vi) + for (Cells_t::iterator vi = m_vecCellAdd.begin(); + vi != m_vecCellAdd.end(); ++vi) { - SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi); - OSL_ASSERT(pAccCell != NULL ); - pAccCell->FireAccessibleEvent(aEvent); + // fdo#57197: check if the object is still alive + uno::Reference<XAccessible> const xAcc(vi->second); + if (xAcc.is()) + { + SwAccessibleContext *const pAccCell(vi->first); + assert(pAccCell); + pAccCell->FireAccessibleEvent(aEvent); + } } return ; } @@ -1760,15 +1767,17 @@ void SwAccessibleTable::FireSelectionEvent( ) } } -void SwAccessibleTable::AddSelectionCell(const SwAccessibleContext* pAccCell, bool bAddOrRemove) +void SwAccessibleTable::AddSelectionCell( + SwAccessibleContext *const pAccCell, bool const bAddOrRemove) { + uno::Reference<XAccessible> const xTmp(pAccCell); if (bAddOrRemove) { - m_vecCellAdd.push_back(pAccCell); + m_vecCellAdd.push_back(std::make_pair(pAccCell, xTmp)); } else { - m_vecCellRemove.push_back(pAccCell); + m_vecCellRemove.push_back(std::make_pair(pAccCell, xTmp)); } } diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx index 88f5916e1b86..2bbd14ffe7d6 100644 --- a/sw/source/core/access/acctable.hxx +++ b/sw/source/core/access/acctable.hxx @@ -266,11 +266,12 @@ public: // XAccessibleComponent sal_Int32 SAL_CALL getBackground() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; - typedef std::vector<const SwAccessibleContext*> VEC_CELL; - VEC_CELL m_vecCellAdd; - VEC_CELL m_vecCellRemove; + typedef std::vector< ::std::pair<SwAccessibleContext*, + css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t; + Cells_t m_vecCellAdd; + Cells_t m_vecCellRemove; void FireSelectionEvent( ); - void AddSelectionCell(const SwAccessibleContext* , bool bAddOrRemove); + void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove); }; inline SwAccessibleTableData_Impl& SwAccessibleTable::GetTableData() |