File 0001-QSystemLocale-bail-out-if-accessed-post-destruction.patch of Package qt6-base

From 2ef615228bba9a8eb282437bfb7472f925610e89 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Fri, 24 Jan 2025 10:28:30 -0800
Subject: [PATCH] QSystemLocale: bail out if accessed post-destruction

There's little we can do, but a lot of content ends up in QLocale very
late in the execution. Let's at least not crash.

Task-number: QTBUG-133206
Change-Id: I77d41141cb115147f9befffdd5e69dac19c96044
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit e32f28034ad2383393645777bcd96eab3f696076)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit d5c5f9f3529b384d0d4bea2d51f0ad6a3d57481d)
---
 src/corelib/text/qlocale_unix.cpp | 2 ++
 src/corelib/text/qlocale_win.cpp  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index a934f24c016..91dbb74c207 100644
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -127,6 +127,8 @@ QLocale QSystemLocale::fallbackLocale() const
 QVariant QSystemLocale::query(QueryType type, QVariant &&in) const
 {
     QSystemLocaleData *d = qSystemLocaleData();
+    if (!d)
+        return QVariant();
 
     if (type == LocaleChanged) {
         d->readEnvironment();
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 9fdb46a4c92..793751daaf0 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -828,6 +828,8 @@ QLocale QSystemLocale::fallbackLocale() const
 QVariant QSystemLocale::query(QueryType type, QVariant &&in) const
 {
     QSystemLocalePrivate *d = systemLocalePrivate();
+    if (!d)
+        return QVariant();
     switch(type) {
     case DecimalPoint:
         return d->decimalPoint();
-- 
2.48.1

openSUSE Build Service is sponsored by