From b2b1d0269261b6050947d94ad5ed8bb8d56c7578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 17 Jan 2024 13:23:06 +0100 Subject: [PATCH] wasm: remove onLanguageChanged event handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QSystemLocale is setting the global window.onLanguageChanged property which may cause conflicts in cases where there are more than one Qt app instance on the same web page. In addition the QSystemLocale destructor never runs, which breaks also for repeated QLocale instantiations on the same page (for example for the QLocale auto- test) Change-Id: I85af0587527b2922804fc866c83864f677700e6d Reviewed-by: Tor Arne Vestbø (cherry picked from commit 3f74e2a633a809a27e8e66346e052dea48c4369e) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qlocale.cpp | 11 ----------- src/corelib/text/qlocale_p.h | 3 --- 2 files changed, 14 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 7e74712ac75..65af3a012d9 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -720,17 +720,6 @@ QSystemLocale::QSystemLocale() : next(_systemLocale) _systemLocale = this; systemLocaleData.m_language_id = 0; - -#ifdef Q_OS_WASM - onLanguageChanged = std::make_unique( - emscripten::val::global("window"), "languagechange", [](emscripten::val) { - systemLocaleData.m_language_id = 0; - QEvent languageChangeEvent(QEvent::LanguageChange); - QCoreApplication::sendEvent(qApp, &languageChangeEvent); - QEvent localeChangeEvent(QEvent::LocaleChange); - QCoreApplication::sendEvent(qApp, &localeChangeEvent); - }); -#endif } /*! diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index aa429e1e3ba..ee0a28e94ec 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -106,9 +106,6 @@ struct QLocaleData; class Q_CORE_EXPORT QSystemLocale { QSystemLocale *next = nullptr; // Maintains a stack. -#ifdef Q_OS_WASM - std::unique_ptr onLanguageChanged; -#endif public: QSystemLocale();