From 3e2706dd7145283256a436951d3aebf591b72428 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 16 Mar 2024 20:30:31 +0200 Subject: [PATCH] drop the feature to change the default locale changing the default locale can have various bad effects (such as failure to convert localized integers stored in QString) which is why there was a warning about it. even tho UNIX has the concept of changing the locale settings (via setlocale()) I am not willing to support such feature because QWidget, QValidtor, etc. have their own locale feature that can be changed at any time Signed-off-by: Ivailo Monev --- src/core/codecs/qtextcodec.cpp | 10 +---- src/core/global/qnamespace.h | 4 +- src/core/global/qnamespace.qdoc | 12 ------ src/core/qcorecommon_p.h | 14 +++++++ src/core/tools/qdatetime.cpp | 46 ----------------------- src/core/tools/qlocale.cpp | 48 ++++-------------------- src/core/tools/qlocale.h | 1 - src/core/tools/qlocale.qdoc | 14 +++---- src/core/tools/qstring.cpp | 19 ++++------ src/gui/kernel/qwidget.cpp | 4 +- src/gui/widgets/qvalidator.cpp | 8 ++-- tests/auto/qdate/tst_qdate.cpp | 11 +----- tests/auto/qdatetime/tst_qdatetime.cpp | 20 +--------- tests/auto/qlocale/tst_qlocale.cpp | 48 ------------------------ tests/auto/qstringref/tst_qstringref.cpp | 18 --------- tests/auto/qtime/tst_qtime.cpp | 11 +----- 16 files changed, 48 insertions(+), 240 deletions(-) diff --git a/src/core/codecs/qtextcodec.cpp b/src/core/codecs/qtextcodec.cpp index 84461814d..28c8cba7c 100644 --- a/src/core/codecs/qtextcodec.cpp +++ b/src/core/codecs/qtextcodec.cpp @@ -981,15 +981,7 @@ QByteArray qt_locale_codec() return localecodec; } - // Get the first non-empty value from $LC_ALL, $LC_CTYPE, and $LANG - // environment variables. - QByteArray lang = qgetenv("LC_ALL"); - if (lang.isEmpty()) { - lang = qgetenv("LC_CTYPE"); - } - if (lang.isEmpty()) { - lang = qgetenv("LANG"); - } + const QByteArray lang = qGetLang(); const int indexOfDot = lang.indexOf('.'); if (indexOfDot != -1) { diff --git a/src/core/global/qnamespace.h b/src/core/global/qnamespace.h index 394056c95..94a949859 100644 --- a/src/core/global/qnamespace.h +++ b/src/core/global/qnamespace.h @@ -812,9 +812,7 @@ public: TextDate, // default Qt ISODate, // ISO 8601 SystemLocaleShortDate, - SystemLocaleLongDate, - DefaultLocaleShortDate, - DefaultLocaleLongDate + SystemLocaleLongDate }; enum TimeSpec { diff --git a/src/core/global/qnamespace.qdoc b/src/core/global/qnamespace.qdoc index 86357ba50..a0d67bff1 100644 --- a/src/core/global/qnamespace.qdoc +++ b/src/core/global/qnamespace.qdoc @@ -445,21 +445,9 @@ \value SystemLocaleLongDate The \l{QLocale::LongFormat}{long format} used by the \l{QLocale::system()}{operating system}. - \value DefaultLocaleShortDate The \l{QLocale::ShortFormat}{short format} specified - by the \l{QLocale::setDefault()}{application's locale}. - - \value DefaultLocaleLongDate The \l{QLocale::LongFormat}{long format} used - by the \l{QLocale::setDefault()}{application's locale}. - \value SystemLocaleDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate instead (or Qt::SystemLocaleLongDate if you want long dates). - \value LocaleDate \e{This enum value is deprecated.} Use Qt::DefaultLocaleShortDate - instead (or Qt::DefaultLocaleLongDate if you want long dates). - - \value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate - instead (or Qt::SystemLocaleLongDate if you want long dates). - \note For \c ISODate formats, each \c Y, \c M and \c D represents a single digit of the year, month and day used to specify the date. Each \c H, \c M and \c S represents a single digit of the hour, minute and second used to specify the time. diff --git a/src/core/qcorecommon_p.h b/src/core/qcorecommon_p.h index 700a7a967..6ad201aa2 100644 --- a/src/core/qcorecommon_p.h +++ b/src/core/qcorecommon_p.h @@ -123,6 +123,20 @@ static inline QStringList qGetEnvList(const char* const name) return result; } +// Get the first non-empty value from $LC_ALL, $LC_CTYPE and $LANG environment +// variables. +static inline QByteArray qGetLang() +{ + QByteArray result = qgetenv("LC_ALL"); + if (result.isEmpty()) { + result = qgetenv("LC_CTYPE"); + } + if (result.isEmpty()) { + result = qgetenv("LANG"); + } + return result; +} + QT_END_NAMESPACE #endif // QCORECOMMON_P_H diff --git a/src/core/tools/qdatetime.cpp b/src/core/tools/qdatetime.cpp index fde63a863..f4738e83f 100644 --- a/src/core/tools/qdatetime.cpp +++ b/src/core/tools/qdatetime.cpp @@ -628,14 +628,6 @@ QString QDate::longDayName(int weekday, MonthNameType type) QLocale::system().toString(date, QLocale::ShortFormat) or QLocale::system().toString(date, QLocale::LongFormat). - If the \a format is Qt::DefaultLocaleShortDate or - Qt::DefaultLocaleLongDate, the string format depends on the - default application locale. This is the locale set with - QLocale::setDefault(), or the system locale if no default locale - has been set. Identical to calling QLocale().toString(date, - QLocale::ShortFormat) or QLocale().toString(date, - QLocale::LongFormat). - If the date is invalid, an empty string will be returned. \warning The Qt::ISODate format is only valid for years in the @@ -655,10 +647,6 @@ QString QDate::toString(Qt::DateFormat f) const case Qt::SystemLocaleLongDate: return QLocale::system().toString(*this, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); - case Qt::DefaultLocaleShortDate: - case Qt::DefaultLocaleLongDate: - return QLocale().toString(*this, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat); #ifndef QT_NO_TEXTDATE case Qt::TextDate: { return QString::fromLatin1("%0 %1 %2 %3") @@ -1019,11 +1007,6 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f) return QLocale::system().toDate(s, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); - case Qt::DefaultLocaleShortDate: - case Qt::DefaultLocaleLongDate: - return QLocale().toDate(s, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat); - #ifndef QT_NO_TEXTDATE case Qt::TextDate: { QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts); @@ -1395,14 +1378,6 @@ int QTime::msec() const QLocale::system().toString(time, QLocale::ShortFormat) or QLocale::system().toString(time, QLocale::LongFormat). - If the \a format is Qt::DefaultLocaleShortDate or - Qt::DefaultLocaleLongDate, the string format depends on the - default application locale. This is the locale set with - QLocale::setDefault(), or the system locale if no default locale - has been set. Identical to calling QLocale().toString(time, - QLocale::ShortFormat) or QLocale().toString(time, - QLocale::LongFormat). - If the time is invalid, an empty string will be returned. */ @@ -1417,11 +1392,6 @@ QString QTime::toString(Qt::DateFormat format) const return QLocale::system().toString(*this, format == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); } - case Qt::DefaultLocaleShortDate: - case Qt::DefaultLocaleLongDate: { - return QLocale().toString(*this, format == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat); - } case Qt::ISODate: case Qt::TextDate: { QSTACKARRAY(char, snprintfbuf, 9); @@ -1656,10 +1626,6 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f) return QLocale::system().toTime(s, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); - case Qt::DefaultLocaleShortDate: - case Qt::DefaultLocaleLongDate: - return QLocale().toTime(s, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat); case Qt::ISODate: case Qt::TextDate: { bool ok = true; @@ -2230,14 +2196,6 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) QLocale::system().toString(datetime, QLocale::ShortFormat) or QLocale::system().toString(datetime, QLocale::LongFormat). - If the \a format is Qt::DefaultLocaleShortDate or - Qt::DefaultLocaleLongDate, the string format depends on the - default application locale. This is the locale set with - QLocale::setDefault(), or the system locale if no default locale - has been set. Identical to calling QLocale().toString(datetime, - QLocale::ShortFormat) or QLocale().toString(datetime, - QLocale::LongFormat). - If the datetime is invalid, an empty string will be returned. \warning The Qt::ISODate format is only valid for years in the @@ -2941,10 +2899,6 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) return QLocale::system().toDateTime(s, f == Qt::SystemLocaleLongDate ? QLocale::LongFormat : QLocale::ShortFormat); - case Qt::DefaultLocaleShortDate: - case Qt::DefaultLocaleLongDate: - return QLocale().toDateTime(s, f == Qt::DefaultLocaleLongDate ? QLocale::LongFormat - : QLocale::ShortFormat); #if !defined(QT_NO_TEXTDATE) case Qt::TextDate: { QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts); diff --git a/src/core/tools/qlocale.cpp b/src/core/tools/qlocale.cpp index 608196920..fc8572114 100644 --- a/src/core/tools/qlocale.cpp +++ b/src/core/tools/qlocale.cpp @@ -156,14 +156,7 @@ static const QLocalePrivate *findLocale(const QByteArray &name) static const QLocalePrivate *defaultPrivate() { if (!default_lp) { - QByteArray lang = qgetenv("LC_ALL"); - if (lang.isEmpty()) { - lang = qgetenv("LC_CTYPE"); - } - if (lang.isEmpty()) { - lang = qgetenv("LANG"); - } - default_lp = findLocale(lang); + default_lp = findLocale(qGetLang()); } return default_lp; } @@ -340,11 +333,10 @@ QLocale::QLocale(const QString &name) } /*! - Constructs a QLocale object initialized with the default locale. If - no default locale was set using setDefaultLocale(), this locale will - be the same as the one returned by system(). + Constructs a QLocale object initialized with the default locale. This + locale will be the same as the one returned by system(). - \sa setDefault() + \sa system() */ QLocale::QLocale() @@ -363,13 +355,13 @@ QLocale::QLocale() is \c AnyCountry, the language is used with the most appropriate available country (for example, Germany for German), \i If neither the language nor the country are found, QLocale - defaults to the default locale (see setDefault()). + defaults to the system locale (see system()). \endlist The language and country that are actually used can be queried using language() and country(). - \sa setDefault() language() country() + \sa system() language() country() */ QLocale::QLocale(Language language, Country country) @@ -401,13 +393,13 @@ QLocale::QLocale(Language language, Country country) language is used with the first locale that matches the given \a script and \a country. \i If neither the language nor the country are found, QLocale - defaults to the default locale (see setDefault()). + defaults to the system locale (see system()). \endlist The language, script and country that are actually used can be queried using language(), script() and country(). - \sa setDefault() language() script() country() + \sa system() language() script() country() */ QLocale::QLocale(Language language, Script script, Country country) @@ -473,29 +465,6 @@ QLocale::NumberOptions QLocale::numberOptions() const return p.numberOptions; } -/*! - \nonreentrant - - Sets the global default locale to \a locale. These - values are used when a QLocale object is constructed with - no arguments. If this function is not called, the system's - locale is used. - - \warning In a multithreaded application, the default locale - should be set at application startup, before any non-GUI threads - are created. - - \sa system() c() -*/ - -void QLocale::setDefault(const QLocale &locale) -{ - default_lp = locale.d(); - default_number_options = locale.numberOptions(); - - qt_initLocale(locale.bcp47Name()); -} - /*! Returns the language of this locale. @@ -1316,7 +1285,6 @@ QString QLocale::toString(double i, char f, int prec) const \sa c() */ - QLocale QLocale::system() { QByteArray lang = qgetenv("LC_ALL"); diff --git a/src/core/tools/qlocale.h b/src/core/tools/qlocale.h index d0fb6397e..7ce3246fc 100644 --- a/src/core/tools/qlocale.h +++ b/src/core/tools/qlocale.h @@ -1371,7 +1371,6 @@ public: static QString languageToString(Language language); static QString countryToString(Country country); static QString scriptToString(Script script); - static void setDefault(const QLocale &locale); static QLocale c() { return QLocale(C); } static QLocale system(); diff --git a/src/core/tools/qlocale.qdoc b/src/core/tools/qlocale.qdoc index f6fca8913..0e624f47d 100644 --- a/src/core/tools/qlocale.qdoc +++ b/src/core/tools/qlocale.qdoc @@ -36,19 +36,17 @@ \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 0 - QLocale supports the concept of a default locale, which is + QLocale supports the concept of a system locale, which is determined from the system's locale settings at application - startup. The default locale can be changed by calling the - static member setDefault(). Setting the default locale has the - following effects: + startup. The default locale has the following effects: \list \i If a QLocale object is constructed with the default constructor, - it will use the default locale's settings. + it will use the system locale's settings. \i QString::toInt(), QString::toDouble(), etc., interpret the - string according to the default locale. If this fails, it + string according to the system locale. If this fails, it falls back on the "C" locale. - \i QString::arg() uses the default locale to format a number when + \i QString::arg() uses the system locale to format a number when its position specifier in the format string contains an 'L', e.g. "%L1". \endlist @@ -66,7 +64,7 @@ is \c AnyCountry, the language is used with the most appropriate available country (for example, Germany for German), \i If neither the language nor the country are found, QLocale - defaults to the default locale (see setDefault()). + defaults to the system locale (see system()). \endlist Use language() and country() to determine the actual language and diff --git a/src/core/tools/qstring.cpp b/src/core/tools/qstring.cpp index dbd91d120..6c27e4e1b 100644 --- a/src/core/tools/qstring.cpp +++ b/src/core/tools/qstring.cpp @@ -5046,8 +5046,7 @@ ushort QString::toUShort(bool *ok, int base) const This function tries to interpret the string according to the current locale. The current locale is determined from the - system at application startup and can be changed by calling - QLocale::setDefault(). If the string cannot be interpreted + system at application startup. If the string cannot be interpreted according to the current locale, this function falls back on the "C" locale. @@ -5061,7 +5060,7 @@ ushort QString::toUShort(bool *ok, int base) const \snippet doc/src/snippets/qstring/main.cpp 68 - \sa number() QLocale::setDefault() QLocale::toDouble() trimmed() + \sa number() QLocale::system() QLocale::toDouble() trimmed() */ double QString::toDouble(bool *ok) const @@ -5837,9 +5836,8 @@ QString QString::arg(const QString &a, int fieldWidth, const QChar &fillChar) co The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of \a a. The conversion - uses the default locale, set by QLocale::setDefault(). If no default - locale was specified, the "C" locale is used. The 'L' flag is - ignored if \a base is not 10. + uses the system locale. If no locale was specified, the "C" locale + is used. The 'L' flag is ignored if \a base is not 10. \snippet doc/src/snippets/qstring/main.cpp 12 \snippet doc/src/snippets/qstring/main.cpp 14 @@ -5874,9 +5872,8 @@ QString QString::arg(const QString &a, int fieldWidth, const QChar &fillChar) co The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of \a a. The conversion uses the default locale. The default locale is determined from the - system's locale settings at application startup. It can be changed - using QLocale::setDefault(). The 'L' flag is ignored if \a base is - not 10. + system's locale settings at application startup. The 'L' flag is + ignored if \a base is not 10. \snippet doc/src/snippets/qstring/main.cpp 12 \snippet doc/src/snippets/qstring/main.cpp 14 @@ -6062,8 +6059,8 @@ QString QString::arg(char a, int fieldWidth, const QChar &fillChar) const The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of \a a. The conversion - uses the default locale, set by QLocale::setDefaultLocale(). If no - default locale was specified, the "C" locale is used. + uses the system locale. If no locale was specified, the "C" locale + is used. If \a fillChar is '0' (the number 0, ASCII 48), this function will use the locale's zero to pad. For negative numbers, the zero padding diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 64d56c61b..d828387fe 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4601,12 +4601,12 @@ QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget As long as no special locale has been set, this is either the parent's locale or (if this widget is a top level widget), - the default locale. + the system locale. If the widget displays dates or numbers, these should be formatted using the widget's locale. - \sa QLocale QLocale::setDefault() + \sa QLocale QLocale::system() */ void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp index d22368465..ccd882f75 100644 --- a/src/gui/widgets/qvalidator.cpp +++ b/src/gui/widgets/qvalidator.cpp @@ -156,12 +156,10 @@ QLocale QValidator::locale() const } /*! - Sets the \a locale that will be used for the validator. Unless - setLocale has been called, the validator will use the default - locale set with QLocale::setDefault(). If a default locale has not - been set, it is the operating system's locale. + Sets the \a locale that will be used for the validator. If a locale has + not been set, it is the operating system's locale. - \sa locale() QLocale::setDefault() + \sa locale() QLocale::system() */ void QValidator::setLocale(const QLocale &locale) { diff --git a/tests/auto/qdate/tst_qdate.cpp b/tests/auto/qdate/tst_qdate.cpp index 4f626886d..2924e909f 100644 --- a/tests/auto/qdate/tst_qdate.cpp +++ b/tests/auto/qdate/tst_qdate.cpp @@ -739,15 +739,8 @@ void tst_QDate::yearsZeroToNinetyNine() void tst_QDate::toString() { QDate date(1974,12,1); - QCOMPARE(date.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(date, QLocale::ShortFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(date.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); } void tst_QDate::negativeYear() const diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index dacf18109..a5663a443 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -1520,32 +1520,14 @@ void tst_QDateTime::fromString() QDateTime dt2(QDate(1999, 1, 18), QTime(11, 49, 00)); - QLocale def; - QLocale::setDefault(QLocale(QLocale::French, QLocale::France)); - - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2); + // QDateTime QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2); - - // obsolete - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2); - - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleLongDate), Qt::DefaultLocaleLongDate), dt2); QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleLongDate), Qt::SystemLocaleLongDate), dt2); - - // same thing for QDate and QTime - - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.date()); QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.date()); QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.date()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.time()); QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.time()); QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.time()); - - QLocale::setDefault(def); } void tst_QDateTime::utcOffset() diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index d5deebabc..6db084109 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -167,29 +167,12 @@ void tst_QLocale::ctor() TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry) TEST_CTOR(Spanish, LatinAmerica, QLocale::Spanish, QLocale::LatinAmerica) - QLocale::setDefault(QLocale(QLocale::English, QLocale::France)); - - { - QLocale l; - QVERIFY(l.language() == QLocale::English); - QVERIFY(l.country() == QLocale::world); - } - TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom) TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry) TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry) - TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::world) - - QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); - - { - QLocale l; - QVERIFY(l.language() == QLocale::English); - QVERIFY(l.country() == QLocale::UnitedKingdom); - } TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom) @@ -197,17 +180,6 @@ void tst_QLocale::ctor() TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry) TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry) - QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::France)); - - { - QLocale l; - QVERIFY(l.language() == QLocale::English); - QVERIFY(l.country() == QLocale::UnitedKingdom); - } - - TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom) - TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom) - TEST_CTOR(English, AnyCountry, QLocale::English, QLocale::UnitedStates) TEST_CTOR(English, UnitedStates, QLocale::English, QLocale::UnitedStates) TEST_CTOR(English, world, QLocale::English, QLocale::world) @@ -218,18 +190,6 @@ void tst_QLocale::ctor() TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry) TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry) - QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::AnyCountry)); - - { - QLocale l; - QVERIFY(l.language() == QLocale::English); - QVERIFY(l.country() == QLocale::UnitedKingdom); - } - - - TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom) - TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom) - TEST_CTOR(English, AnyCountry, QLocale::English, QLocale::UnitedStates) TEST_CTOR(English, UnitedStates, QLocale::English, QLocale::UnitedStates) TEST_CTOR(English, world, QLocale::English, QLocale::world) @@ -266,8 +226,6 @@ void tst_QLocale::ctor() + "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \ } - QLocale::setDefault(QLocale(QLocale::C)); - QChar c; TEST_CTOR("C", C, AnyCountry) TEST_CTOR("bla", C, AnyCountry) @@ -438,8 +396,6 @@ void tst_QLocale::unixLocaleName() QCOMPARE(l.name(), QString(exp_name)); \ } - QLocale::setDefault(QLocale(QLocale::C)); - TEST_NAME(C, AnyCountry, "C") TEST_NAME(English, world, "en_001") TEST_NAME(English, AnyCountry, "en_US") @@ -717,10 +673,6 @@ void tst_QLocale::long_long_conversion_extra() void tst_QLocale::languageToString() { } - -void tst_QLocale::setDefault() -{ -} */ void tst_QLocale::testInfAndNan() diff --git a/tests/auto/qstringref/tst_qstringref.cpp b/tests/auto/qstringref/tst_qstringref.cpp index 9ae6a745c..a9849df4c 100644 --- a/tests/auto/qstringref/tst_qstringref.cpp +++ b/tests/auto/qstringref/tst_qstringref.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include // This next bit is needed for the NAN and INF in string -> number conversion tests @@ -43,12 +42,8 @@ class tst_QStringRef : public QObject public: tst_QStringRef(); - virtual ~tst_QStringRef(); -public slots: - void init(); - void cleanup(); private slots: void endsWith(); void startsWith(); @@ -87,19 +82,6 @@ tst_QStringRef::tst_QStringRef() { } -tst_QStringRef::~tst_QStringRef() -{ -} - -void tst_QStringRef::init() -{ -} - -void tst_QStringRef::cleanup() -{ - QLocale::setDefault(QString(QLatin1Char('C'))); -} - void tst_QStringRef::length_data() { QTest::addColumn("s1"); diff --git a/tests/auto/qtime/tst_qtime.cpp b/tests/auto/qtime/tst_qtime.cpp index 590ebea55..50a57a772 100644 --- a/tests/auto/qtime/tst_qtime.cpp +++ b/tests/auto/qtime/tst_qtime.cpp @@ -652,15 +652,8 @@ void tst_QTime::toString_format() void tst_QTime::toStringLocale() { QTime time(18, 30); - QCOMPARE(time.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(time, QLocale::ShortFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(time.toString(Qt::SystemLocaleShortDate), - QLocale::system().toString(time, QLocale::ShortFormat)); - QCOMPARE(time.toString(Qt::DefaultLocaleShortDate), - QLocale().toString(time, QLocale::ShortFormat)); + QCOMPARE(time.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(time, QLocale::ShortFormat)); + QCOMPARE(time.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(time, QLocale::ShortFormat)); } QTEST_APPLESS_MAIN(tst_QTime)