summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qlocale.cpp15
-rw-r--r--src/corelib/tools/qlocale_p.h2
-rw-r--r--src/corelib/tools/qlocale_unix.cpp70
-rw-r--r--src/corelib/tools/qsimd.cpp6
-rw-r--r--src/corelib/tools/qstring.cpp10
-rw-r--r--src/corelib/tools/tools.pri1
6 files changed, 63 insertions, 41 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 086ca7bd38..e40917c5d8 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -46,13 +46,6 @@
#include "qglobal.h"
-#ifndef QT_NO_SYSTEMLOCALE
-QT_BEGIN_NAMESPACE
-class QSystemLocale;
-static QSystemLocale *QSystemLocale_globalSystemLocale();
-QT_END_NAMESPACE
-#endif
-
#include "qplatformdefs.h"
#include "qdatastream.h"
@@ -78,7 +71,13 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_SYSTEMLOCALE
static QSystemLocale *_systemLocale = 0;
-Q_GLOBAL_STATIC_WITH_ARGS(QSystemLocale, QSystemLocale_globalSystemLocale, (true))
+class QSystemLocaleSingleton: public QSystemLocale
+{
+public:
+ QSystemLocaleSingleton() : QSystemLocale(true) {}
+};
+
+Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
static QLocalePrivate *system_lp = 0;
Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
#endif
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index ad7c9706c4..377a60881f 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -122,7 +122,7 @@ public:
private:
QSystemLocale(bool);
- friend QSystemLocale *QSystemLocale_globalSystemLocale();
+ friend class QSystemLocaleSingleton;
};
#endif
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index f2876912b4..e88c511ae9 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -45,6 +45,7 @@
#include "qdatetime.h"
#include "qstringlist.h"
#include "qvariant.h"
+#include "qreadwritelock.h"
QT_BEGIN_NAMESPACE
@@ -57,29 +58,13 @@ struct QSystemLocaleData
,lc_monetary(QLocale::C)
,lc_messages(QLocale::C)
{
- QByteArray all = qgetenv("LC_ALL");
- QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all;
- QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all;
- QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all;
- lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all;
- lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all;
- QByteArray lang = qgetenv("LANG");
- if (lang.isEmpty())
- lang = QByteArray("C");
- if (numeric.isEmpty())
- numeric = lang;
- if (monetary.isEmpty())
- monetary = lang;
- if (lc_messages_var.isEmpty())
- lc_messages_var = lang;
- if (lc_measurement_var.isEmpty())
- lc_measurement_var = lang;
- lc_numeric = QLocale(QString::fromLatin1(numeric));
- lc_time = QLocale(QString::fromLatin1(time));
- lc_monetary = QLocale(QString::fromLatin1(monetary));
- lc_messages = QLocale(QString::fromLatin1(lc_messages_var));
+ readEnvironment();
}
+ void readEnvironment();
+
+ QReadWriteLock lock;
+
QLocale lc_numeric;
QLocale lc_time;
QLocale lc_monetary;
@@ -87,10 +72,43 @@ struct QSystemLocaleData
QByteArray lc_messages_var;
QByteArray lc_measurement_var;
};
+
+void QSystemLocaleData::readEnvironment()
+{
+ QWriteLocker locker(&lock);
+
+ QByteArray all = qgetenv("LC_ALL");
+ QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all;
+ QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all;
+ QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all;
+ lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all;
+ lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all;
+ QByteArray lang = qgetenv("LANG");
+ if (lang.isEmpty())
+ lang = QByteArray("C");
+ if (numeric.isEmpty())
+ numeric = lang;
+ if (time.isEmpty())
+ time = lang;
+ if (monetary.isEmpty())
+ monetary = lang;
+ if (lc_messages_var.isEmpty())
+ lc_messages_var = lang;
+ if (lc_measurement_var.isEmpty())
+ lc_measurement_var = lang;
+ lc_numeric = QLocale(QString::fromLatin1(numeric));
+ lc_time = QLocale(QString::fromLatin1(time));
+ lc_monetary = QLocale(QString::fromLatin1(monetary));
+ lc_messages = QLocale(QString::fromLatin1(lc_messages_var));
+}
+
+
Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData)
+
#endif
#ifndef QT_NO_SYSTEMLOCALE
+
QLocale QSystemLocale::fallbackLocale() const
{
QByteArray lang = qgetenv("LC_ALL");
@@ -104,6 +122,14 @@ QLocale QSystemLocale::fallbackLocale() const
QVariant QSystemLocale::query(QueryType type, QVariant in) const
{
QSystemLocaleData *d = qSystemLocaleData();
+
+ if (type == LocaleChanged) {
+ d->readEnvironment();
+ return QVariant();
+ }
+
+ QReadLocker locker(&d->lock);
+
const QLocale &lc_numeric = d->lc_numeric;
const QLocale &lc_time = d->lc_time;
const QLocale &lc_monetary = d->lc_monetary;
@@ -216,6 +242,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation);
case ListToSeparatedString:
return lc_messages.createSeparatedList(in.value<QStringList>());
+ case LocaleChanged:
+ Q_ASSERT(false);
default:
break;
}
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 6c07480f99..a74a140582 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -320,12 +320,6 @@ static inline uint detectProcessorFeatures()
return features;
}
-#elif defined(__ia64__)
-static inline uint detectProcessorFeatures()
-{
- return MMX|SSE|SSE2;
-}
-
#else
static inline uint detectProcessorFeatures()
{
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index cf09e2b5dc..bb66fdbdec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -122,11 +122,11 @@ static inline int qt_find_latin1_string(const QChar *hay, int size, const QLatin
static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
- const QLatin1String &needle, Qt::CaseSensitivity cs);
+ QLatin1String needle, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
- const QLatin1String &needle, Qt::CaseSensitivity cs);
+ QLatin1String needle, Qt::CaseSensitivity cs);
// Unicode case-insensitive comparison
static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be)
@@ -2753,7 +2753,7 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity
int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
{
return qt_last_index_of(unicode(), size(), ch, from, cs);
- }
+}
/*!
\since 4.8
@@ -8988,7 +8988,7 @@ static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
}
static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
- const QLatin1String &needle, Qt::CaseSensitivity cs)
+ QLatin1String needle, Qt::CaseSensitivity cs)
{
if (!haystack)
return !needle.latin1();
@@ -9039,7 +9039,7 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
- const QLatin1String &needle, Qt::CaseSensitivity cs)
+ QLatin1String needle, Qt::CaseSensitivity cs)
{
if (!haystack)
return !needle.latin1();
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index ac347404fd..ec02454c67 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -29,6 +29,7 @@ HEADERS += \
tools/qmargins.h \
tools/qcontiguouscache.h \
tools/qpodlist_p.h \
+ tools/qpair.h \
tools/qpoint.h \
tools/qqueue.h \
tools/qrect.h \