From 58db7e9e0713dad6da02cefa461101f0ac79cab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 24 Mar 2010 10:47:43 +0100 Subject: Revert "Optimized QLocale to access system locale on demand." This reverts commit 0d3c62150f2fa2c06f7676336076be4622059cc3, which causes the following (intermittent) test failuers: TESTCASE_FAIL qtconcurrentmap (pulse_qws/linux-x86-g++) TESTFUNCTION_FAIL qtconcurrentmap::mapped (pulse_qws/linux-x86-g++) --- src/corelib/tools/qlocale.cpp | 214 ++++++++----------------------------- src/corelib/tools/qlocale.h | 1 - src/corelib/tools/qlocale_p.h | 18 ++-- tests/auto/qlocale/tst_qlocale.cpp | 6 -- 4 files changed, 54 insertions(+), 185 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index caa47d0..c3f6783 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1274,25 +1274,11 @@ QLocale QSystemLocale::fallbackLocale() const */ QVariant QSystemLocale::query(QueryType type, QVariant /* in */) const { - switch (type) { - case MeasurementSystem: + if (type == MeasurementSystem) { return QVariant(unixGetSystemMeasurementSystem()); - case LanguageId: - case CountryId: { - QString locale = QLatin1String(envVarLocale()); - QLocale::Language lang; - QLocale::Country cntry; - getLangAndCountry(locale, lang, cntry); - if (type == LanguageId) - return lang; - if (cntry == QLocale::AnyCountry) - return fallbackLocale().country(); - return cntry; - } - default: - break; + } else { + return QVariant(); } - return QVariant(); } #elif !defined(Q_OS_SYMBIAN) @@ -1324,10 +1310,12 @@ QVariant QSystemLocale::query(QueryType /* type */, QVariant /* in */) const #endif +#ifndef QT_NO_SYSTEMLOCALE static QSystemLocale *_systemLocale = 0; Q_GLOBAL_STATIC_WITH_ARGS(QSystemLocale, QSystemLocale_globalSystemLocale, (true)) static QLocalePrivate *system_lp = 0; Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate) +#endif /****************************************************************************** ** Default system locale behavior @@ -1400,8 +1388,7 @@ QSystemLocale::QSystemLocale() /*! \internal */ QSystemLocale::QSystemLocale(bool) -{ -} +{ } /*! Deletes the object. @@ -1423,42 +1410,16 @@ static const QSystemLocale *systemLocale() return QSystemLocale_globalSystemLocale(); } -static const QLocalePrivate *maybeSystemPrivate(); -bool QLocalePrivate::isUninitializedSystemLocale() const -{ - return this == maybeSystemPrivate() && m_language_id == 0; -} - -QVariant QLocalePrivate::querySystemLocale(int type, const QVariant &in) const -{ - QVariant res = systemLocale()->query(QSystemLocale::QueryType(type), in); - if (res.isNull() && isUninitializedSystemLocale()) { - // if we were not able to get data from the system, initialize the - // system locale private data (which is essentially equals to this) - // with a fallback locale. - QLocalePrivate *system_private = globalLocalePrivate(); - *system_private = *systemLocale()->fallbackLocale().d(); - // internal cache is not initialized with values from the system, mark - // it as not fully initialized system locale. - system_private->m_language_id = 0; - } - return res; -} - -// retrieves data from the system locale and caches them locally. void QLocalePrivate::updateSystemPrivate() { const QSystemLocale *sys_locale = systemLocale(); if (!system_lp) - return; - - // copy over the information from the fallback locale and modify + system_lp = globalLocalePrivate(); *system_lp = *sys_locale->fallbackLocale().d(); QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); if (!res.isNull()) system_lp->m_language_id = res.toInt(); - res = sys_locale->query(QSystemLocale::CountryId, QVariant()); if (!res.isNull()) system_lp->m_country_id = res.toInt(); @@ -1485,29 +1446,19 @@ void QLocalePrivate::updateSystemPrivate() } #endif -// returns the private data for the system locale. Cached data will not be -// initialized until the updateSystemPrivate is called. static const QLocalePrivate *systemPrivate() { #ifndef QT_NO_SYSTEMLOCALE - if (!system_lp) { - system_lp = globalLocalePrivate(); - // mark the locale as uninitialized system locale - system_lp->m_language_id = 0; - } + // copy over the information from the fallback locale and modify + if (!system_lp || system_lp->m_language_id == 0) + QLocalePrivate::updateSystemPrivate(); + return system_lp; #else return locale_data; #endif } -#ifndef QT_NO_SYSTEMLOCALE -static const QLocalePrivate *maybeSystemPrivate() -{ - return system_lp; -} -#endif - static const QLocalePrivate *defaultPrivate() { if (!default_lp) @@ -2386,12 +2337,7 @@ void QLocale::setDefault(const QLocale &locale) */ QLocale::Language QLocale::language() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return Language(dd->languageId()); + return Language(d()->languageId()); } /*! @@ -2401,12 +2347,7 @@ QLocale::Language QLocale::language() const */ QLocale::Country QLocale::country() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return Country(dd->countryId()); + return Country(d()->countryId()); } /*! @@ -2744,8 +2685,8 @@ QString QLocale::toString(const QDate &date, FormatType format) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort, date); if (!res.isNull()) @@ -2839,8 +2780,8 @@ QString QLocale::toString(const QDateTime &dateTime, FormatType format) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::DateTimeToStringLong : QSystemLocale::DateTimeToStringShort, dateTime); @@ -2865,8 +2806,8 @@ QString QLocale::toString(const QTime &time, FormatType format) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort, time); if (!res.isNull()) @@ -2892,8 +2833,8 @@ QString QLocale::toString(const QTime &time, FormatType format) const QString QLocale::dateFormat(FormatType format) const { #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort, QVariant()); if (!res.isNull()) @@ -2929,8 +2870,8 @@ QString QLocale::dateFormat(FormatType format) const QString QLocale::timeFormat(FormatType format) const { #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort, QVariant()); if (!res.isNull()) @@ -2966,8 +2907,8 @@ QString QLocale::timeFormat(FormatType format) const QString QLocale::dateTimeFormat(FormatType format) const { #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(format == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(format == LongFormat ? QSystemLocale::DateTimeFormatLong : QSystemLocale::DateTimeFormatShort, QVariant()); @@ -3134,12 +3075,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons */ QChar QLocale::decimalPoint() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->decimal(); + return d()->decimal(); } /*! @@ -3149,12 +3085,7 @@ QChar QLocale::decimalPoint() const */ QChar QLocale::groupSeparator() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->group(); + return d()->group(); } /*! @@ -3164,12 +3095,7 @@ QChar QLocale::groupSeparator() const */ QChar QLocale::percent() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->percent(); + return d()->percent(); } /*! @@ -3179,12 +3105,7 @@ QChar QLocale::percent() const */ QChar QLocale::zeroDigit() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->zero(); + return d()->zero(); } /*! @@ -3194,12 +3115,7 @@ QChar QLocale::zeroDigit() const */ QChar QLocale::negativeSign() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->minus(); + return d()->minus(); } /*! @@ -3209,12 +3125,7 @@ QChar QLocale::negativeSign() const */ QChar QLocale::positiveSign() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->plus(); + return d()->plus(); } /*! @@ -3224,12 +3135,7 @@ QChar QLocale::positiveSign() const */ QChar QLocale::exponential() const { - const QLocalePrivate *dd = d(); -#ifndef QT_NO_SYSTEMLOCALE - if (dd->isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif - return dd->exponential(); + return d()->exponential(); } static bool qIsUpper(char c) @@ -3348,8 +3254,8 @@ QString QLocale::monthName(int month, FormatType type) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(type == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(type == LongFormat ? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort, month); if (!res.isNull()) @@ -3394,8 +3300,8 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(type == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(type == LongFormat ? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort, month); if (!res.isNull()) @@ -3441,8 +3347,8 @@ QString QLocale::dayName(int day, FormatType type) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(type == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(type == LongFormat ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort, day); if (!res.isNull()) @@ -3490,8 +3396,8 @@ QString QLocale::standaloneDayName(int day, FormatType type) const return QString(); #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(type == LongFormat + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(type == LongFormat ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort, day); if (!res.isNull()) @@ -3535,8 +3441,8 @@ QLocale::MeasurementSystem QLocale::measurementSystem() const bool found = false; #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(QSystemLocale::MeasurementSystem, QVariant()); + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(QSystemLocale::MeasurementSystem, QVariant()); if (!res.isNull()) { meas = MeasurementSystem(res.toInt()); found = true; @@ -3563,8 +3469,8 @@ QLocale::MeasurementSystem QLocale::measurementSystem() const QString QLocale::amText() const { #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(QSystemLocale::AMText, QVariant()); + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(QSystemLocale::AMText, QVariant()); if (!res.isNull()) return res.toString(); } @@ -3583,8 +3489,8 @@ QString QLocale::amText() const QString QLocale::pmText() const { #ifndef QT_NO_SYSTEMLOCALE - if (d() == maybeSystemPrivate()) { - QVariant res = d()->querySystemLocale(QSystemLocale::PMText, QVariant()); + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(QSystemLocale::PMText, QVariant()); if (!res.isNull()) return res.toString(); } @@ -3999,10 +3905,6 @@ QString QLocalePrivate::doubleToString(double d, int width, unsigned flags) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif if (precision == -1) precision = 6; if (width == -1) @@ -4153,10 +4055,6 @@ QString QLocalePrivate::longLongToString(qlonglong l, int precision, int base, int width, unsigned flags) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif bool precision_not_specified = false; if (precision == -1) { precision_not_specified = true; @@ -4242,10 +4140,6 @@ QString QLocalePrivate::unsLongLongToString(qulonglong l, int precision, int base, int width, unsigned flags) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif bool precision_not_specified = false; if (precision == -1) { precision_not_specified = true; @@ -4448,10 +4342,6 @@ bool QLocalePrivate::numberToCLocale(const QString &num, bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif buff->clear(); buff->reserve(str.length()); @@ -4545,10 +4435,6 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte double QLocalePrivate::stringToDouble(const QString &number, bool *ok, GroupSeparatorMode group_sep_mode) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif CharBuff buff; if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number, group_sep_mode, &buff)) { @@ -4562,10 +4448,6 @@ double QLocalePrivate::stringToDouble(const QString &number, bool *ok, qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base, bool *ok, GroupSeparatorMode group_sep_mode) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif CharBuff buff; if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number, group_sep_mode, &buff)) { @@ -4580,10 +4462,6 @@ qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base, qulonglong QLocalePrivate::stringToUnsLongLong(const QString &number, int base, bool *ok, GroupSeparatorMode group_sep_mode) const { -#ifndef QT_NO_SYSTEMLOCALE - if (isUninitializedSystemLocale()) - QLocalePrivate::updateSystemPrivate(); -#endif CharBuff buff; if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number, group_sep_mode, &buff)) { diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 3b4e9dc..ac05c86 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -691,7 +691,6 @@ public: ; private: friend struct QLocalePrivate; - // ### We now use this field to pack an index into locale_data and NumberOptions. // ### Qt 5: change to a QLocaleData *d; uint numberOptions. union { diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 003ae8c..ecf79e9 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -63,14 +63,14 @@ QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QLocalePrivate { public: - QChar decimal() const { Q_ASSERT(m_decimal); return QChar(m_decimal); } - QChar group() const { Q_ASSERT(m_group); return QChar(m_group); } - QChar list() const { Q_ASSERT(m_list); return QChar(m_list); } - QChar percent() const { Q_ASSERT(m_percent); return QChar(m_percent); } - QChar zero() const { Q_ASSERT(m_zero); return QChar(m_zero); } - QChar plus() const { Q_ASSERT(m_plus); return QChar(m_plus); } - QChar minus() const { Q_ASSERT(m_minus); return QChar(m_minus); } - QChar exponential() const { Q_ASSERT(m_exponential); return QChar(m_exponential); } + QChar decimal() const { return QChar(m_decimal); } + QChar group() const { return QChar(m_group); } + QChar list() const { return QChar(m_list); } + QChar percent() const { return QChar(m_percent); } + QChar zero() const { return QChar(m_zero); } + QChar plus() const { return QChar(m_plus); } + QChar minus() const { return QChar(m_minus); } + QChar exponential() const { return QChar(m_exponential); } quint32 languageId() const { return m_language_id; } quint32 countryId() const { return m_country_id; } @@ -132,8 +132,6 @@ public: CharBuff *result) const; inline char digitToCLocale(const QChar &c) const; - inline bool isUninitializedSystemLocale() const; - QVariant querySystemLocale(int type, const QVariant &in) const; static void updateSystemPrivate(); enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode }; diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 21a6f32..182f73b 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -158,15 +158,9 @@ void tst_QLocale::ctor() QCoreApplication app(argc, (char**)&argv); #endif QLocale default_locale = QLocale::system(); - - QVERIFY(!default_locale.monthName(1, QLocale::LongFormat).isEmpty()); - QVERIFY(!default_locale.monthName(1, QLocale::ShortFormat).isEmpty()); - QVERIFY(default_locale.language() != 0); - QLocale::Language default_lang = default_locale.language(); QLocale::Country default_country = default_locale.country(); - qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(), QLocale::countryToString(default_country).toLatin1().constData()); -- cgit v0.12 From 67ff95079522d79e45d64d579856c5c1cd3a69d9 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 24 Mar 2010 10:11:10 +0100 Subject: Add a check to make sure QTranslator doesn't load a directory. Merge-request: 531 Reviewed-by: Benjamin Poulain --- src/corelib/kernel/qtranslator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 7d1e1d3..ca54c6c 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -412,12 +412,12 @@ bool QTranslator::load(const QString & filename, const QString & directory, realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); fi.setFile(realname); - if (fi.isReadable()) + if (fi.isReadable() && fi.isFile()) break; realname = prefix + fname; fi.setFile(realname); - if (fi.isReadable()) + if (fi.isReadable() && fi.isFile()) break; int rightmost = 0; -- cgit v0.12 From 423f1cf2c5bd505497400db1e732efad12361976 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 24 Mar 2010 10:11:11 +0100 Subject: Add unit tests for QTranslator. Two new tests: * Check that translations can be loaded from resources * Check that nothing happens when trying to "load" a directory Merge-request: 531 Reviewed-by: Benjamin Poulain --- tests/auto/qtranslator/qtranslator.pro | 2 +- tests/auto/qtranslator/qtranslator.qrc | 5 +++++ tests/auto/qtranslator/tst_qtranslator.cpp | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qtranslator/qtranslator.qrc diff --git a/tests/auto/qtranslator/qtranslator.pro b/tests/auto/qtranslator/qtranslator.pro index 30ffc1c..2b08b4a 100644 --- a/tests/auto/qtranslator/qtranslator.pro +++ b/tests/auto/qtranslator/qtranslator.pro @@ -1,6 +1,6 @@ load(qttest_p4) SOURCES += tst_qtranslator.cpp - +RESOURCES += qtranslator.qrc wince*|symbian*: { addFiles.sources = hellotr_la.qm msgfmt_from_po.qm diff --git a/tests/auto/qtranslator/qtranslator.qrc b/tests/auto/qtranslator/qtranslator.qrc new file mode 100644 index 0000000..333dcfa --- /dev/null +++ b/tests/auto/qtranslator/qtranslator.qrc @@ -0,0 +1,5 @@ + + + hellotr_la.qm + + diff --git a/tests/auto/qtranslator/tst_qtranslator.cpp b/tests/auto/qtranslator/tst_qtranslator.cpp index 44fc10c..f2bfbf0 100644 --- a/tests/auto/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/qtranslator/tst_qtranslator.cpp @@ -70,6 +70,8 @@ private slots: void testLanguageChange(); void plural(); void translate_qm_file_generated_with_msgfmt(); + void loadFromResource(); + void loadDirectory(); private: int languageChangeEventCounter; @@ -237,5 +239,22 @@ void tst_QTranslator::translate_qm_file_generated_with_msgfmt() qApp->removeTranslator(&translator); } +void tst_QTranslator::loadFromResource() +{ + QTranslator tor; + tor.load(":/tst_qtranslator/hellotr_la.qm"); + QVERIFY(!tor.isEmpty()); + QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!")); +} + +void tst_QTranslator::loadDirectory() +{ + QVERIFY(QFileInfo("../qtranslator").isDir()); + + QTranslator tor; + tor.load("qtranslator", ".."); + QVERIFY(tor.isEmpty()); +} + QTEST_MAIN(tst_QTranslator) #include "tst_qtranslator.moc" -- cgit v0.12 From 63f13c0f2793fa0833d906be409f57362f6971d7 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 24 Mar 2010 11:55:57 +0100 Subject: Fix compile error with QT_NO_HTTP Reviewed-by: Benjamin Poulain --- src/network/access/qnetworkreplyimpl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 7fc0097..edd6889 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -318,11 +318,15 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const // for HTTP, we want to send out the request as fast as possible to the network, without // invoking methods in a QueuedConnection +#ifndef QT_NO_HTTP if (qobject_cast(backend)) { _q_startOperation(); } else { QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); } +#else + QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); +#endif // QT_NO_HTTP } q->QIODevice::open(QIODevice::ReadOnly); @@ -872,11 +876,15 @@ bool QNetworkReplyImplPrivate::migrateBackend() backend->setResumeOffset(bytesDownloaded); } +#ifndef QT_NO_HTTP if (qobject_cast(backend)) { _q_startOperation(); } else { QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); } +#else + QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); +#endif // QT_NO_HTTP return true; } -- cgit v0.12 From 666c6b5b18c013d4fe6eb67a4c7106047513e43a Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 24 Mar 2010 12:33:07 +0100 Subject: Wrong position for foucs ring when used in QMacNativeWidget. This widget is treated as a window by Qt, but with the embedded flag ON. setGeometry should not clip this window, it will be cliped automatically by the parent view of QMacNativeWidget. Task-number: QTBUG-9199 Reviewed-by: Denis --- src/gui/kernel/qwidget_mac.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b3a6aec..ef7373c 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4067,7 +4067,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) QRect xrect = data.crect; QRect parentWRect; - if (q->isWindow() && topData()->embedded) { + bool isEmbeddedWindow = (q->isWindow() && topData()->embedded); + if (isEmbeddedWindow) { #ifndef QT_MAC_USE_COCOA HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q)); #else @@ -4092,7 +4093,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) if (parentWRect.isValid()) { // parent is clipped, and we have to clip to the same limit as parent - if (!parentWRect.contains(xrect)) { + if (!parentWRect.contains(xrect) && !isEmbeddedWindow) { xrect &= parentWRect; wrect = xrect; //translate from parent's to my Qt coord sys -- cgit v0.12