sw/inc/AnnotationWin.hxx                  |    3 +++
 sw/source/uibase/docvw/AnnotationWin.cxx  |    1 +
 sw/source/uibase/docvw/AnnotationWin2.cxx |   15 +++++++++------
 3 files changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 819b30e937d227d1458ecc22b09ef994ebe7e17e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 19 14:47:19 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 19 18:18:53 2021 +0200

    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.gran...@collabora.co.uk>

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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to