aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qdeclarativelocale.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp12
2 files changed, 16 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativelocale.cpp b/src/declarative/qml/qdeclarativelocale.cpp
index ae57edb941..9f2116f8fd 100644
--- a/src/declarative/qml/qdeclarativelocale.cpp
+++ b/src/declarative/qml/qdeclarativelocale.cpp
@@ -811,7 +811,10 @@ v8::Handle<v8::Value> QDeclarativeLocale::locale(QV8Engine *v8engine, const QStr
QV8LocaleDataDeletable *d = localeV8Data(v8engine);
v8::Local<v8::Object> v8Value = d->constructor->NewInstance();
QV8LocaleDataResource *r = new QV8LocaleDataResource(v8engine);
- r->locale = QLocale(locale);
+ if (locale.isEmpty())
+ r->locale = QLocale();
+ else
+ r->locale = QLocale(locale);
v8Value->SetExternalResource(r);
return v8Value;
diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
index b2f35fd8b3..d49122c889 100644
--- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
+++ b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
@@ -54,6 +54,8 @@ public:
tst_qdeclarativelocale() { }
private slots:
+ void defaultLocale();
+
void properties_data();
void properties();
void currencySymbol_data();
@@ -114,6 +116,16 @@ private:
QDeclarativeEngine engine;
};
+void tst_qdeclarativelocale::defaultLocale()
+{
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QCOMPARE(obj->property("name").toString(), QLocale().name());
+}
+
#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }
void tst_qdeclarativelocale::addPropertyData(const QString &l)