sw/source/uibase/uiview/view.cxx |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 97fa167baa062ef4d26053924527d114e0394fff
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Aug 13 16:58:50 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Aug 13 17:26:50 2024 +0200

    Handle possible exceptions in SwView::ImpSetVerb
    
    This reportedly may crash on unhandled exception, with the following stack:
    
     KernelBase.dll!00007ffaa227fabc()
     [External Code]
     emboleobj.dll!OleComponent::GetVerbList() Line 1013
            at D:\lombeddedobj\source\msole\olecomponent.cxx(1013)
     emboleobj.dll!OleEmbeddedObject::getSupportedVerbs() Line 1000
            at D:\lombeddedobj\source\msole\oleembed.cxx(1000)
     swlo.dll!SwView::ImpSetVerb(SelectionType nSelType) Line 162
            at D:\lo\sw\source\uibase\uiviewiew.cxx(162)
     swlo.dll!SwView::SelectShell() Line 309
            at D:\lo\sw\source\uibase\uiviewiew.cxx(309)
     swlo.dll!SwView::AttrChangedNotify(LinkParamNone * __formal) Line 574
            at D:\lo\sw\source\uibase\uiviewiew.cxx(574)
     [Inline Frame] swlo.dll!Link<LinkParamNone *,void>::Call(LinkParamNone *) 
Line 111
            at D:\lo\include    ools\link.hxx(111)
     swlo.dll!SwCursorShell::CallChgLnk() Line 2903
            at D:\lo\sw\source     swlo.dll!SwRootFrame::EndAllAction() Line 
1941
            at D:\lo\sw\source     
swlo.dll!UnoActionContext::~UnoActionContext() Line 212
            at D:\lo\sw\source     swlo.dll!SwXFrame::setPropertyValue(const 
rtl::OUString & rPropertyName, const com::sun::star::uno::Any & _rValue) Line 
1605
            at D:\lo\sw\source     mscx_uno.dll!`anonymous 
namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, 
bridges::cpp_uno::shared::VtableSlot aVtableSlot, 
_typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, 
_typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, 
_uno_Any * * ppUnoExc) Line 214
            at D:\loridges\source     
mscx_uno.dll!unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const 
_typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any 
* * ppException) Line 430
            at D:\loridges\source     
binaryurplo.dll!binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny 
* returnValue, 
std::vector<binaryurp::BinaryAny,std::allocator<binaryurp::BinaryAny> > * 
outArguments) Line 239
            at D:\loinaryurp\source\incomingrequest.cxx(239)
     binaryurplo.dll!binaryurp::IncomingRequest::execute() Line 79
            at D:\loinaryurp\source\incomingrequest.cxx(79)
     binaryurplo.dll!request(void * pThreadSpecificData) Line 84
            at D:\loinaryurp\source eader.cxx(84)
     cppu3.dll!cppu_threadpool::JobQueue::enter(const void * nDisposeId, bool 
bReturnWhenNoJob) Line 101
            at D:\lo     cppu3.dll!cppu_threadpool::ORequestThread::run() Line 
169
            at D:\lo     cppu3.dll!threadFunc(void * param) Line 190
            at D:\lo\include\osl        hread.hxx(190)
     sal3.dll!oslWorkerWrapperFunction(void * pData) Line 67
            at D:\lo\sal\osl\w32        hread.cxx(67)
    
    Change-Id: Ifef15938c7986c4179d61cfa07973ad9b13d4ad4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171823
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 1bd82e27f0dd..046ef7c41490 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -26,6 +26,7 @@
 
 #include <stdlib.h>
 #include <hintids.hxx>
+#include <comphelper/diagnose_ex.hxx>
 #include <comphelper/string.hxx>
 #include <comphelper/lok.hxx>
 #include <o3tl/any.hxx>
@@ -149,7 +150,7 @@ SfxDispatcher &SwView::GetDispatcher()
 
 void SwView::ImpSetVerb( SelectionType nSelType )
 {
-    bool bResetVerbs = m_bVerbsActive;
+    Sequence<embed::VerbDescriptor> newVerbs;
     if ( !GetViewFrame().GetFrame().IsInPlace() &&
          (SelectionType::Ole|SelectionType::Graphic) & nSelType )
     {
@@ -158,16 +159,21 @@ void SwView::ImpSetVerb( SelectionType nSelType )
         {
             if ( nSelType & SelectionType::Ole )
             {
-                SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
-                m_bVerbsActive = true;
-                bResetVerbs = false;
+                try
+                {
+                    newVerbs = 
GetWrtShell().GetOLEObject()->getSupportedVerbs();
+                }
+                catch (css::uno::Exception&)
+                {
+                    DBG_UNHANDLED_EXCEPTION("sw.ui", "Failed to retrieve 
supported verbs");
+                }
             }
         }
     }
-    if ( bResetVerbs )
+    if (m_bVerbsActive || newVerbs.hasElements())
     {
-        SetVerbs( Sequence< embed::VerbDescriptor >() );
-        m_bVerbsActive = false;
+        SetVerbs(newVerbs);
+        m_bVerbsActive = newVerbs.hasElements();
     }
 }
 

Reply via email to