desktop/source/app/appinit.cxx |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 24a3a7c72714c4f45c46cd2b6274013503d444d6
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue Sep 3 09:38:58 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Tue Sep 3 13:47:21 2024 +0200

    Emscripten: workerID is only defined under -sASSERTIONS
    
    ...and explicitly passing in pthread_self() on the calling side is better 
than
    trying to identify the calling thread on the callee side, anyway
    
    Change-Id: Ib26a7cbdede246280b6985b6eb1582baf172bf59
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172786
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index 3a8bce551d6a..16f023b0a414 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -93,20 +93,13 @@ EM_JS(void, setupMainChannel, (), {
     };
 });
 
-extern "C" void resolveUnoMain() {
-    EM_ASM(
-        let sofficeMain;
-        for (const i in PThread.pthreads) {
-            const worker = PThread.pthreads[i];
-            if (worker.workerID === 1) {
-                sofficeMain = worker;
-                break;
-            }
-        }
+extern "C" void resolveUnoMain(pthread_t id) {
+    EM_ASM({
+        const sofficeMain = PThread.pthreads[$0];
         const channel = new MessageChannel();
         sofficeMain.postMessage({cmd:"LOWA-channel"}, [channel.port2]);
         Module.uno_main$resolve(channel.port1);
-    );
+    }, id);
 }
 
 void initUno() {
@@ -120,7 +113,7 @@ void initUno() {
         runUnoScriptUrl(url.getStr());
     }
     setupMainChannel();
-    emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_V, resolveUnoMain);
+    emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_VI, 
resolveUnoMain, pthread_self());
 }
 
 }

Reply via email to