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

New commits:
commit 56328e0ae06e5c5342df3b0b51dbc90d1d964b31
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Mon Mar 10 12:12:08 2025 +0100
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Tue Mar 11 08:12: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.)
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182731
    Reviewed-by: Stephan Bergmann <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 376466a7451843be90d1ee12a3a7a2b65113e575)
    Conflicts:
            vcl/source/window/dialog.cxx
    
    Change-Id: I143747cc32fb163e4908fa42b031e4eaea697d29
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182736
    Reviewed-by: Stephan Bergmann <[email protected]>
    Tested-by: allotropia jenkins <[email protected]>

diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx
index 5e11d2f783b5..9c0bb7ba585f 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 83a8e8babaf2..c0b0c5012d2c 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -904,7 +904,7 @@ bool Dialog::Close()
     }
 }
 
-bool Dialog::ImplStartExecute()
+bool Dialog::ImplStartExecute(bool async)
 {
     setDeferredProperties();
 
@@ -940,6 +940,14 @@ bool Dialog::ImplStartExecute()
             
SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));
 #endif
         }
+        if (!async && Application::IsOnSystemEventLoop())
+        {
+            // 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() )
         {
@@ -1069,7 +1077,7 @@ short Dialog::Execute()
             mbInSyncExecute = false;
         });
 
-    if ( !ImplStartExecute() )
+    if ( !ImplStartExecute(false) )
         return 0;
 
     // Yield util EndDialog is called or dialog gets destroyed
@@ -1108,7 +1116,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