summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-19 14:47:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-19 18:18:53 +0200
commit819b30e937d227d1458ecc22b09ef994ebe7e17e (patch)
tree9ec5bb91ed27c6dcf4674cb91488183dbccb4e49
parent928ce6043523a70d056d15210296d627d6223c2f (diff)
tdf#142367 Writer crashes when opening docx
regression from commit 5aa60be574ece81b27c8f63e6e809871c694dba0 fix leak in VCLXWindow Make SwAnnotationWin follow the same pattern as all the other code and return a custom accessibility object instead of trying to override the toolkit peer object. Change-Id: Ifa3a5da2fbbf082e6bb05281cc9d354d6ec3ba03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115805 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/AnnotationWin.hxx3
-rw-r--r--sw/source/uibase/docvw/AnnotationWin.cxx1
-rw-r--r--sw/source/uibase/docvw/AnnotationWin2.cxx15
3 files changed, 13 insertions, 6 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index f1ba8a499589..6cf6760aeb2b 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -49,6 +49,7 @@ namespace sw::sidebarwindows {
class SidebarTextControl;
class AnchorOverlayObject;
class ShadowOverlayObject;
+ class SidebarWinAccessible;
}
@@ -271,6 +272,8 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public InterimItemWindow
SwFormatField* mpFormatField;
SwPostItField* mpField;
+
+ rtl::Reference<sw::sidebarwindows::SidebarWinAccessible> mxSidebarWinAccessible;
};
} // end of namespace sw::annotation
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index 49ea845944b8..e354a62204a8 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -62,6 +62,7 @@
#include "AnchorOverlayObject.hxx"
#include "OverlayRanges.hxx"
#include "SidebarTxtControl.hxx"
+#include "SidebarWinAcc.hxx"
#include <memory>
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index f463bf7597f1..b2604377e2e0 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1376,8 +1376,8 @@ void SwAnnotationWin::ChangeSidebarItem( SwSidebarItem const & rSidebarItem )
mrSidebarItem = rSidebarItem;
mpAnchorFrame = mrSidebarItem.maLayoutInfo.mpAnchorFrame;
- if (SidebarWinAccessible* pAcc = dynamic_cast<SidebarWinAccessible*>(GetWindowPeer()))
- pAcc->ChangeSidebarItem( mrSidebarItem );
+ if (mxSidebarWinAccessible)
+ mxSidebarWinAccessible->ChangeSidebarItem( mrSidebarItem );
if ( bAnchorChanged )
{
@@ -1389,11 +1389,14 @@ void SwAnnotationWin::ChangeSidebarItem( SwSidebarItem const & rSidebarItem )
css::uno::Reference< css::accessibility::XAccessible > SwAnnotationWin::CreateAccessible()
{
- rtl::Reference<SidebarWinAccessible> pAcc( new SidebarWinAccessible( *this,
+ // This is rather dodgy code. Normally in CreateAccessible, if we want a custom
+ // object, we return a custom object, but we do no override the default toolkit
+ // window peer.
+ if (!mxSidebarWinAccessible)
+ mxSidebarWinAccessible = new SidebarWinAccessible( *this,
mrView.GetWrtShell(),
- mrSidebarItem ) );
- SetWindowPeer( pAcc, pAcc.get() );
- return pAcc;
+ mrSidebarItem );
+ return mxSidebarWinAccessible;
}
} // eof of namespace sw::sidebarwindows