Skip to content

Commit

Permalink
Return a string from resolvedUrl() to match 4.x behavior
Browse files Browse the repository at this point in the history
Task-number: QTBUG-20960
Change-Id: I9ae99ada5c9bbe7498df24908c6acd202ca73a15
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
  • Loading branch information
Aaron Kennedy authored and Qt by Nokia committed Nov 9, 2011
1 parent da8d168 commit 0c5f918
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp
Expand Up @@ -676,12 +676,12 @@ v8::Handle<v8::Value> resolvedUrl(const v8::Arguments &args)
if (p) {
QDeclarativeContextData *ctxt = V8ENGINE()->callingContext();
if (ctxt)
return V8ENGINE()->fromVariant(ctxt->resolvedUrl(url));
return V8ENGINE()->toString(ctxt->resolvedUrl(url).toString());
else
return V8ENGINE()->fromVariant(url);
return V8ENGINE()->toString(url.toString());
}

return V8ENGINE()->fromVariant(e->baseUrl().resolved(url));
return V8ENGINE()->toString(e->baseUrl().resolved(url).toString());
}

/*!
Expand Down
13 changes: 13 additions & 0 deletions tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml
@@ -0,0 +1,13 @@
import QtQuick 2.0

QtObject {
property string result
property bool isString: false

Component.onCompleted: {
var a = Qt.resolvedUrl("resolvedUrl.qml");
result = a;
isString = (typeof a) == "string"
}
}

14 changes: 14 additions & 0 deletions tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
Expand Up @@ -89,6 +89,7 @@ private slots:
void atob();
void fontFamilies();
void quit();
void resolvedUrl();

private:
QDeclarativeEngine engine;
Expand Down Expand Up @@ -727,6 +728,19 @@ void tst_qdeclarativeqt::quit()
delete object;
}

void tst_qdeclarativeqt::resolvedUrl()
{
QDeclarativeComponent component(&engine, TEST_FILE("resolvedUrl.qml"));

QObject *object = component.create();
QVERIFY(object != 0);

QCOMPARE(object->property("result").toString(), component.url().toString());
QCOMPARE(object->property("isString").toBool(), true);

delete object;
}

QTEST_MAIN(tst_qdeclarativeqt)

#include "tst_qdeclarativeqt.moc"

0 comments on commit 0c5f918

Please sign in to comment.