svx/source/accessibility/AccessibleTextHelper.cxx |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 71dd214624675afe3267d467d588afd1ce3eb693
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat May 28 20:04:40 2022 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun May 29 12:40:19 2022 +0200

    Fix failing assert on shutdown with NVDA active
    
    The stack trace at the moment of calling implLookupClient with
    nClient == -1 was:
    
    > ucrtbased.dll!abort() Line 61 C++
    > ucrtbased.dll!common_assert_to_stderr<wchar_t>(const wchar_t * const 
expression, const wchar_t * const file_name, const unsigned int line_number) 
Line 187    C++
    > ucrtbased.dll!common_assert<wchar_t>(const wchar_t * const expression, 
const wchar_t * const file_name, const unsigned int line_number, void * const 
return_address) Line 420 C++
    > ucrtbased.dll!_wassert(const wchar_t * expression, const wchar_t * 
file_name, unsigned int line_number) Line 444      C++
    > comphelper.dll!`anonymous namespace'::implLookupClient(const unsigned 
long nClient, 
std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<unsigned 
long const 
,comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 *>>>> & rPos) Line 139  C++
    > comphelper.dll!comphelper::AccessibleEventNotifier::addEvent(const 
unsigned long _nClient, const 
com::sun::star::accessibility::AccessibleEventObject & _rEvent) Line 249     C++
    > svxlo.dll!accessibility::AccessibleTextHelper_Impl::FireEvent(const 
com::sun::star::accessibility::AccessibleEventObject & rEvent) Line 1416  C++
    > svxlo.dll!accessibility::AccessibleTextHelper_Impl::FireEvent(const short 
nEventId, const com::sun::star::uno::Any & rNewValue, const 
com::sun::star::uno::Any & rOldValue) Line 1408 C++
    > svxlo.dll!accessibility::AccessibleTextHelper_Impl::ShutdownEditSource() 
Line 700     C++
    > 
svxlo.dll!accessibility::AccessibleTextHelper_Impl::SetEditSource(std::unique_ptr<SvxEditSource,std::default_delete<SvxEditSource>>
 && pEditSource) Line 717  C++
    > 
svxlo.dll!accessibility::AccessibleTextHelper::SetEditSource(std::unique_ptr<SvxEditSource,std::default_delete<SvxEditSource>>
 && pEditSource) Line 1548      C++
    > svxlo.dll!WeldEditAccessible::ClearWin() Line 552     C++
    > svxlo.dll!WeldEditView::~WeldEditView() Line 864      C++
    > smlo.dll!SmEditTextWindow::~SmEditTextWindow() Line 85        C++
    > smlo.dll!SmEditTextWindow::`scalar deleting destructor'(unsigned int) C++
    > 
smlo.dll!std::default_delete<SmEditTextWindow>::operator()(SmEditTextWindow * 
_Ptr) Line 3129 C++
    > 
smlo.dll!std::unique_ptr<SmEditTextWindow,std::default_delete<SmEditTextWindow>>::reset(SmEditTextWindow
 * _Ptr) Line 3276    C++
    > smlo.dll!SmEditWindow::DeleteEditView() Line 853      C++
    > smlo.dll!SmEditWindow::~SmEditWindow() Line 139       C++
    > smlo.dll!SmEditWindow::`scalar deleting destructor'(unsigned int)     C++
    > smlo.dll!o3tl::default_delete<SmEditWindow>::operator()(SmEditWindow * p) 
Line 46     C++
    > 
smlo.dll!std::unique_ptr<SmEditWindow,o3tl::default_delete<SmEditWindow>>::reset(SmEditWindow
 * _Ptr) Line 3276       C++
    > smlo.dll!SmCmdBoxWindow::dispose() Line 931   C++
    > vcllo.dll!VclReferenceBase::disposeOnce() Line 39     C++
    > sfxlo.dll!VclPtr<vcl::Window>::disposeAndClear() Line 206     C++
    > sfxlo.dll!SfxChildWindow::~SfxChildWindow() Line 198  C++
    > smlo.dll!SmCmdBoxWrapper::~SmCmdBoxWrapper()  C++
    > smlo.dll!SmCmdBoxWrapper::`scalar deleting destructor'(unsigned int)  C++
    > sfxlo.dll!SfxChildWindow::Destroy() Line 176  C++
    > sfxlo.dll!SfxWorkWindow::DeleteControllers_Impl() Line 599    C++
    > sfxlo.dll!SfxFrame::DoClose_Impl() Line 133   C++
    > sfxlo.dll!SfxBaseController::dispose() Line 981       C++
    > fwklo.dll!`anonymous namespace'::XFrameImpl::setComponent(const 
com::sun::star::uno::Reference<com::sun::star::awt::XWindow> & 
xComponentWindow, const 
com::sun::star::uno::Reference<com::sun::star::frame::XController> & 
xController) Line 1485    C++
    > fwklo.dll!`anonymous namespace'::XFrameImpl::close(unsigned char 
bDeliverOwnership) Line 1696 C++
    > fwklo.dll!framework::Desktop::impl_closeFrames(bool bAllowUI) Line 1702   
    C++
    > fwklo.dll!framework::Desktop::terminate() Line 214    C++
    > fwklo.dll!framework::CloseDispatcher::implts_terminateApplication() Line 
543  C++
    > fwklo.dll!framework::CloseDispatcher::impl_asyncCallback(LinkParamNone * 
__formal) Line 397   C++
    > fwklo.dll!framework::CloseDispatcher::LinkStubimpl_asyncCallback(void * 
instance, LinkParamNone * data) Line 245      C++
    > vcllo.dll!Link<LinkParamNone *,void>::Call(LinkParamNone * data) Line 111 
    C++
    > vcllo.dll!vcl::EventPoster::DoEvent_Impl(void * __formal) Line 53     C++
    > vcllo.dll!vcl::EventPoster::LinkStubDoEvent_Impl(void * instance, void * 
data) Line 48        C++
    > vcllo.dll!Link<void *,void>::Call(void * data) Line 111       C++
    > vcllo.dll!ImplHandleUserEvent(ImplSVEvent * pSVEvent) Line 2232       C++
    > vcllo.dll!ImplWindowFrameProc(vcl::Window * _pWindow, SalEvent nEvent, 
const void * pEvent) Line 2800 C++
    > vcllo.dll!SalFrame::CallCallback(SalEvent nEvent, const void * pEvent) 
Line 308       C++
    > vclplug_winlo.dll!ImplHandleUserEvent(HWND__ * hWnd, __int64 lParam) Line 
4214        C++
    > vclplug_winlo.dll!SalFrameWndProc(HWND__ * hWnd, unsigned int nMsg, 
unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 5865   C++
    > vclplug_winlo.dll!SalFrameWndProcW(HWND__ * hWnd, unsigned int nMsg, 
unsigned __int64 wParam, __int64 lParam) Line 5972       C++
    > user32.dll!UserCallWinProcCheckWow()  Unknown
    > user32.dll!DispatchMessageWorker()    Unknown
    > vclplug_winlo.dll!ImplSalDispatchMessage(const tagMSG * pMsg) Line 475    
    C++
    > vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) 
Line 506     C++
    > vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool 
bHandleAllCurrentEvents) Line 581  C++
    > vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 474 C++
    > vcllo.dll!Application::Yield() Line 559       C++
    > vcllo.dll!Application::Execute() Line 452     C++
    > sofficeapp.dll!desktop::Desktop::Main() Line 1600     C++
    > vcllo.dll!ImplSVMain() Line 202       C++
    > vcllo.dll!SVMain() Line 235   C++
    > sofficeapp.dll!soffice_main() Line 94 C++
    > soffice.bin!sal_main() Line 51        C
    > soffice.bin!main(int argc, char * * argv) Line 49     C
    
    Firing the event when we already set the id to mean "revoked"
    seems wrong. Also use the correct type for the id.
    
    Change-Id: Ie2e180c0c8c112023f789968ffa785f046de9d76
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135058
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx 
b/svx/source/accessibility/AccessibleTextHelper.cxx
index 78915e4a8d62..2fa4c0a9b5eb 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -170,7 +170,7 @@ namespace accessibility
 
         virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 
override;
 
-        int getNotifierClientId() const { return mnNotifierClientId; }
+        comphelper::AccessibleEventNotifier::TClientId getNotifierClientId() 
const { return mnNotifierClientId; }
 
         // lock solar mutex before
         SvxTextForwarder& GetTextForwarder() const;
@@ -222,7 +222,9 @@ namespace accessibility
         Point maOffset;
 
         /// client Id from AccessibleEventNotifier
-        int mnNotifierClientId;
+        comphelper::AccessibleEventNotifier::TClientId mnNotifierClientId;
+        static constexpr comphelper::AccessibleEventNotifier::TClientId 
snNotifierClientRevoked
+            = 
std::numeric_limits<comphelper::AccessibleEventNotifier::TClientId>::max();
     };
 
     AccessibleTextHelper_Impl::AccessibleTextHelper_Impl() :
@@ -1353,7 +1355,7 @@ namespace accessibility
 
     void AccessibleTextHelper_Impl::Dispose()
     {
-        if( getNotifierClientId() != -1 )
+        if( getNotifierClientId() != snNotifierClientRevoked)
         {
             try
             {
@@ -1363,7 +1365,7 @@ namespace accessibility
             }
             catch( const uno::Exception& ) {}
 
-            mnNotifierClientId = -1;
+            mnNotifierClientId = snNotifierClientRevoked;
         }
 
         try
@@ -1411,8 +1413,8 @@ namespace accessibility
     void AccessibleTextHelper_Impl::FireEvent( const AccessibleEventObject& 
rEvent ) const
     {
         // #106234# Delegate to EventNotifier
-        ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
-                                                         rEvent );
+        if (getNotifierClientId() != snNotifierClientRevoked)
+            ::comphelper::AccessibleEventNotifier::addEvent( 
getNotifierClientId(), rEvent );
     }
 
     // XAccessibleContext
@@ -1441,13 +1443,13 @@ namespace accessibility
 
     void AccessibleTextHelper_Impl::addAccessibleEventListener( const 
uno::Reference< XAccessibleEventListener >& xListener )
     {
-        if( getNotifierClientId() != -1 )
+        if( getNotifierClientId() != snNotifierClientRevoked )
             ::comphelper::AccessibleEventNotifier::addEventListener( 
getNotifierClientId(), xListener );
     }
 
     void AccessibleTextHelper_Impl::removeAccessibleEventListener( const 
uno::Reference< XAccessibleEventListener >& xListener )
     {
-        if( getNotifierClientId() == -1 )
+        if( getNotifierClientId() == snNotifierClientRevoked )
             return;
 
         const sal_Int32 nListenerCount = 
::comphelper::AccessibleEventNotifier::removeEventListener( 
getNotifierClientId(), xListener );
@@ -1458,7 +1460,7 @@ namespace accessibility
             // and at least to us not firing any events anymore, in case 
somebody calls
             // NotifyAccessibleEvent, again
             ::comphelper::AccessibleEventNotifier::TClientId nId( 
getNotifierClientId() );
-            mnNotifierClientId = -1;
+            mnNotifierClientId = snNotifierClientRevoked;
             ::comphelper::AccessibleEventNotifier::revokeClient( nId );
         }
     }

Reply via email to