Combined backport of [1][2][3] from upcoming Qt 6.8.3 for [4][5][6].

[1] https://github.com/qt/qtbase/commit/12d4bf1ab52748cb84894f50d437064b439e0b7d
[2] https://github.com/qt/qtbase/commit/2ef615228bba9a8eb282437bfb7472f925610e89
[3] https://github.com/qt/qtbase/commit/a43c7e58046604796aa69974ea1c5d3e2648c755
[4] https://bugreports.qt.io/browse/QTBUG-133206
[5] https://bugreports.qt.io/browse/QTBUG-133500
[6] https://bugs.kde.org/show_bug.cgi?id=499537
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -7,4 +7,5 @@
 #include "qfile.h"
 #if QT_CONFIG(settings)
+#include "qresource.h"
 #include "qsettings.h"
 #endif
@@ -104,5 +105,5 @@
 
     QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
-    if (QFile::exists(qtconfig))
+    if (QResource(qtconfig, QLocale::c()).isValid())
         return std::make_unique<QSettings>(qtconfig, QSettings::IniFormat);
 #ifdef Q_OS_DARWIN
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -1113,8 +1113,11 @@
 
 QLocale::QLocale()
-    : d(*defaultLocalePrivate)
+    : d(c_private())
 {
-    // Make sure system data is up to date:
-    systemData();
+    if (!defaultLocalePrivate.isDestroyed()) {
+        // Make sure system data is up to date:
+        systemData();
+        d = *defaultLocalePrivate;
+    }
 }
 
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -128,4 +128,6 @@
 {
     QSystemLocaleData *d = qSystemLocaleData();
+    if (!d)
+        return QVariant();
 
     if (type == LocaleChanged) {
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -829,4 +829,6 @@
 {
     QSystemLocalePrivate *d = systemLocalePrivate();
+    if (!d)
+        return QVariant();
     switch(type) {
     case DecimalPoint:
