summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-12-17 14:11:42 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-12-17 17:26:05 (GMT)
commitd64c29e18cedace91bea31d83b62e5c0b6c6049e (patch)
tree9d577988e6df0b180c286fb384cc4baf1b574e03
parentface84c73a2196432020dda18755af7955d2de39 (diff)
downloadQt-d64c29e18cedace91bea31d83b62e5c0b6c6049e.zip
Qt-d64c29e18cedace91bea31d83b62e5c0b6c6049e.tar.gz
Qt-d64c29e18cedace91bea31d83b62e5c0b6c6049e.tar.bz2
Fixed QResource to respect the explicitely set locale
When using QResource directly, the loader should respect the locale that the user asked to use for the resource. Reviewed-by: João Abecasis
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--tests/auto/qresourceengine/tst_qresourceengine.cpp22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 5c543d4..a061ad1 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -273,7 +273,7 @@ QResourcePrivate::load(const QString &file)
QString cleaned = cleanPath(file);
for(int i = 0; i < list->size(); ++i) {
QResourceRoot *res = list->at(i);
- const int node = res->findNode(cleaned);
+ const int node = res->findNode(cleaned, locale);
if(node != -1) {
if(related.isEmpty()) {
container = res->isContainer(node);
diff --git a/tests/auto/qresourceengine/tst_qresourceengine.cpp b/tests/auto/qresourceengine/tst_qresourceengine.cpp
index cc6eda3..ed7de23 100644
--- a/tests/auto/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/qresourceengine/tst_qresourceengine.cpp
@@ -62,6 +62,7 @@ private slots:
void searchPath_data();
void searchPath();
void doubleSlashInRoot();
+ void setLocale();
private:
QString builddir;
@@ -460,6 +461,27 @@ void tst_QResourceEngine::doubleSlashInRoot()
QVERIFY(QFile::exists("://secondary_root/runtime_resource/search_file.txt"));
}
+void tst_QResourceEngine::setLocale()
+{
+ QLocale::setDefault(QLocale::c());
+
+ // default constructed QResource gets the default locale
+ QResource resource;
+ resource.setFileName("aliasdir/aliasdir.txt");
+ QVERIFY(!resource.isCompressed());
+
+ // change the default locale and make sure it doesn't affect the resource
+ QLocale::setDefault(QLocale("de_CH"));
+ QVERIFY(!resource.isCompressed());
+
+ // then explicitly set the locale on qresource
+ resource.setLocale(QLocale("de_CH"));
+ QVERIFY(resource.isCompressed());
+
+ // the reset the default locale back
+ QLocale::setDefault(QLocale::system());
+}
+
QTEST_MAIN(tst_QResourceEngine)
#include "tst_qresourceengine.moc"