include/vcl/toolkit/dialog.hxx |    2 +-
 vcl/source/window/dialog.cxx   |   14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 376466a7451843be90d1ee12a3a7a2b65113e575
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Mon Mar 10 12:12:08 2025 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Mon Mar 10 13:55:42 2025 +0100

    Emscripten: Pre-cancel synchronous execution of modal dialogs
    
    ...which would run into Application::Yield -> std::abort, so better live 
with
    this hack for now.  (The way forward would be to either asyncify relevant
    dialogs, or move to Qt6 and --enable-emscripten-jspi.)
    
    Change-Id: I143747cc32fb163e4908fa42b031e4eaea697d29
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182731
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Tested-by: Jenkins

diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx
index 818b856b67f9..2207e11d8acd 100644
--- a/include/vcl/toolkit/dialog.hxx
+++ b/include/vcl/toolkit/dialog.hxx
@@ -129,7 +129,7 @@ public:
     virtual FactoryFunction GetUITestFactory() const override;
 
 private:
-    bool            ImplStartExecute();
+    bool            ImplStartExecute(bool async);
     static void     ImplEndExecuteModal();
     void            ImplSetModalInputMode(bool bModal);
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 112c1b7b5b14..39f688911406 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -907,7 +907,7 @@ bool Dialog::Close()
     }
 }
 
-bool Dialog::ImplStartExecute()
+bool Dialog::ImplStartExecute(bool async)
 {
     setDeferredProperties();
 
@@ -951,6 +951,14 @@ bool Dialog::ImplStartExecute()
                 return false;
             }
         }
+        if (!async && Application::IsUseSystemEventLoop())
+        {
+            // As long as Application::Yield deliberately calls std::abort 
when trying to
+            // synchronously execute modal dialogs, better cancel them here 
for now as a hack:
+            SAL_WARN(
+                "vcl", "cancel synchronous execution of modal dialog " << 
ImplGetDialogText(this));
+            return false;
+        }
 
         switch ( Application::GetDialogCancelMode() )
         {
@@ -1081,7 +1089,7 @@ short Dialog::Execute()
             mbInSyncExecute = false;
         });
 
-    if ( !ImplStartExecute() )
+    if ( !ImplStartExecute(false) )
         return 0;
 
     // Yield util EndDialog is called or dialog gets destroyed
@@ -1111,7 +1119,7 @@ short Dialog::Execute()
 bool Dialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx )
 {
     const bool bModal = GetType() != WindowType::MODELESSDIALOG;
-    if (!ImplStartExecute())
+    if (!ImplStartExecute(true))
     {
         rCtx.mxOwner.disposeAndClear();
         rCtx.mxOwnerDialogController.reset();

Reply via email to