Related: tdf#147742 a11y: Dispose table cells as well
When disposing `AccessibleGridControlTable` (which
is done in `AccessibleGridControl::disposing`),
also dispose its cells and clear the references.
Without this in place, a crash sometimes occured
when running the macro in the sample doc from
tdf#147742 several times and clicking around in the
table, with the Orca screen reader active.
This was because a reference to one of
the `AccessibleGridControlTableCell`s was still
around after the `AccessibleGridControlTable`
had already been disposed, and when trying
to get its accessible name, the call to
`IAccessibleTable::GetAccessibleObjectName` in
`AccessibleGridControlCell::getAccessibleName`
would fail because the object that the
`m_aTable` reference was referring to had already
been deleted.
With the cell being disposed as well, the
`ensureIsAlive()` check at the beginning of
`AccessibleGridControlCell::getAccessibleName`
will throw a `DisposedException`, that is then
handled properly in the calling code.
Backtrace (with master as of commit
2598c35dbac8dc4492ad1fc79925c5347e683af0):
#0 0x00007fffd9152ed3 in accessibility::AccessibleGridControlCell::getAccessibleName() (this=0x55555bbcdb70) at /home/michi/development/git/libreoffice/accessibility/source/extended/AccessibleGridControlTableCell.cxx:79
#1 0x00007fffe45e864a in wrapper_get_name(AtkObject*) (atk_obj=0x55555bbcef60) at /home/michi/development/git/libreoffice/vcl/unx/gtk3/a11y/atkwrapper.cxx:369
#2 0x00007fffe3a87e5c in () at /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0
#3 0x00007fffe3a947de in () at /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0
#4 0x00007fffe3a94caf in () at /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0
#5 0x00007ffff75feff0 in () at /lib/x86_64-linux-gnu/libdbus-1.so.3
#6 0x00007ffff75eea1c in dbus_connection_dispatch () at /lib/x86_64-linux-gnu/libdbus-1.so.3
#7 0x00007fffe36d74a5 in () at /lib/x86_64-linux-gnu/libatspi.so.0
#8 0x00007fffe9ab8cdb in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#9 0x00007fffe9ab8f88 in () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#10 0x00007fffe9ab903f in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#11 0x00007fffe460f546 in GtkSalData::Yield(bool, bool) (this=0x55555567c750, bWait=true, bHandleAllCurrentEvents=false) at /home/michi/development/git/libreoffice/vcl/unx/gtk3/gtkdata.cxx:405
#12 0x00007fffe461402a in GtkInstance::DoYield(bool, bool) (this=0x55555567c5d0, bWait=true, bHandleAllCurrentEvents=false) at /home/michi/development/git/libreoffice/vcl/unx/gtk3/gtkinst.cxx:427
#13 0x00007fffef7ab4be in ImplYield(bool, bool) (i_bWait=true, i_bAllEvents=false) at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:474
#14 0x00007fffef7ac0b0 in Application::Yield() () at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:558
#15 0x00007fffef7ab18e in Application::Execute() () at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:452
#16 0x00007ffff7c309af in desktop::Desktop::Main() (this=0x7fffffffd780) at /home/michi/development/git/libreoffice/desktop/source/app/app.cxx:1604
#17 0x00007fffef7c9d75 in ImplSVMain() () at /home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:202
#18 0x00007fffef7c9e96 in SVMain() () at /home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:234
#19 0x00007ffff7c947c9 in soffice_main() () at /home/michi/development/git/libreoffice/desktop/source/app/sofficemain.cxx:98
#20 0x00005555555549f4 in sal_main () at /home/michi/development/git/libreoffice/desktop/source/app/main.c:51
#21 0x00005555555549da in main (argc=4, argv=0x7fffffffdaf8) at /home/michi/development/git/libreoffice/desktop/source/app/main.c:49
Change-Id: Idffa76809cbfad746f27d18191fdfc905b64ee0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131247
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/accessibility/inc/extended/AccessibleGridControlTable.hxx b/accessibility/inc/extended/AccessibleGridControlTable.hxx
index bada751..6023654 100644
--- a/accessibility/inc/extended/AccessibleGridControlTable.hxx
+++ b/accessibility/inc/extended/AccessibleGridControlTable.hxx
@@ -139,6 +139,9 @@ public:
/** @return The name of this class. */
virtual OUString SAL_CALL getImplementationName() override;
// XComponent
virtual void SAL_CALL dispose() override;
/**@return m_pCellVector*/
std::vector< rtl::Reference<AccessibleGridControlTableCell> >& getCellVector() { return m_aCellVector;}
diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx
index a08302b..3c635e9 100644
--- a/accessibility/source/extended/AccessibleGridControlTable.cxx
+++ b/accessibility/source/extended/AccessibleGridControlTable.cxx
@@ -290,6 +290,20 @@ OUString SAL_CALL AccessibleGridControlTable::getImplementationName()
return "com.sun.star.accessibility.AccessibleGridControlTable";
}
void AccessibleGridControlTable::dispose()
{
for (rtl::Reference<AccessibleGridControlTableCell>& rxCell : m_aCellVector)
{
if (rxCell.is())
{
rxCell->dispose();
rxCell.clear();
}
}
AccessibleGridControlTableBase::dispose();
}
void AccessibleGridControlTable::commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue,
const css::uno::Any& rOldValue)
{