From 360f0d00088cc84791e7a197b20a325bfdac9eb3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 20 Apr 2012 09:27:01 +1000 Subject: [PATCH] Use QUrl constructor directly. setEncodedUrl is deprecated, and no longer required as the new QUrl makes this behavior default. This is a partial revert of 3aa53b8bc383ebcdf8dc922b2670170ec012949f. Change-Id: I14f29cbe2a2e2cd9c41f7afc92b1cb66b53996bb Reviewed-by: Matthew Vogt --- src/qml/qml/qqmlcompiler.cpp | 12 ++---------- src/qml/qml/qqmlproperty.cpp | 28 ++++++---------------------- src/qml/qml/v4/qv4bindings.cpp | 4 +--- src/qml/qml/v8/qv8sequencewrapper_p_p.h | 4 +--- 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 54577f9..8c47c7c 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -407,14 +407,6 @@ bool QQmlCompiler::testLiteralAssignment(QQmlScript::Property *prop, return true; } -static QUrl urlFromUserString(const QString &data) -{ - QUrl u; - // Preserve any valid percent-encoded octets supplied by the source - u.setEncodedUrl(data.toUtf8(), QUrl::TolerantMode); - return u; -} - /*! Generate a store instruction for assigning literal \a v to property \a prop. @@ -522,7 +514,7 @@ void QQmlCompiler::genLiteralAssignment(QQmlScript::Property *prop, { Instruction::StoreUrl instr; QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); + QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string)); instr.propertyIndex = prop->index; instr.value = output->indexForUrl(u); output->addInstruction(instr); @@ -721,7 +713,7 @@ void QQmlCompiler::genLiteralAssignment(QQmlScript::Property *prop, } else if (type == qMetaTypeId >()) { Instruction::StoreUrlQList instr; QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); + QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string)); instr.propertyIndex = prop->index; instr.value = output->indexForUrl(u); output->addInstruction(instr); diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 075c1f6..0029861 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1084,22 +1084,6 @@ QVariant QQmlPropertyPrivate::readValueProperty() } } -static QUrl urlFromUserString(const QByteArray &data) -{ - QUrl u; - if (!data.isEmpty()) - { - // Preserve any valid percent-encoded octets supplied by the source - u.setEncodedUrl(data, QUrl::TolerantMode); - } - return u; -} - -static QUrl urlFromUserString(const QString &data) -{ - return urlFromUserString(data.toUtf8()); -} - // helper function to allow assignment / binding to QList properties. static QVariant resolvedUrlSequence(const QVariant &value, QQmlContextData *context) { @@ -1107,19 +1091,19 @@ static QVariant resolvedUrlSequence(const QVariant &value, QQmlContextData *cont if (value.userType() == qMetaTypeId()) { urls.append(value.toUrl()); } else if (value.userType() == qMetaTypeId()) { - urls.append(urlFromUserString(value.toString())); + urls.append(QUrl(value.toString())); } else if (value.userType() == qMetaTypeId()) { - urls.append(urlFromUserString(value.toByteArray())); + urls.append(QUrl(QString::fromUtf8(value.toByteArray()))); } else if (value.userType() == qMetaTypeId >()) { urls = value.value >(); } else if (value.userType() == qMetaTypeId()) { QStringList urlStrings = value.value(); for (int i = 0; i < urlStrings.size(); ++i) - urls.append(urlFromUserString(urlStrings.at(i))); + urls.append(QUrl(urlStrings.at(i))); } else if (value.userType() == qMetaTypeId >()) { QList urlStrings = value.value >(); for (int i = 0; i < urlStrings.size(); ++i) - urls.append(urlFromUserString(urlStrings.at(i))); + urls.append(QUrl(urlStrings.at(i))); } // note: QList is not currently supported. QList resolvedUrls; @@ -1259,10 +1243,10 @@ bool QQmlPropertyPrivate::write(QObject *object, u = value.toUrl(); found = true; } else if (variantType == QVariant::ByteArray) { - u = urlFromUserString(value.toByteArray()); + u = QUrl(QString::fromUtf8(value.toByteArray())); found = true; } else if (variantType == QVariant::String) { - u = urlFromUserString(value.toString()); + u = QUrl(value.toString()); found = true; } diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp index e055cad..db6811f 100644 --- a/src/qml/qml/v4/qv4bindings.cpp +++ b/src/qml/qml/v4/qv4bindings.cpp @@ -1063,9 +1063,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, output.cleanupString(); MARK_CLEAN_REGISTER(instr->unaryop.output); } - QUrl *urlPtr = output.geturlptr(); - new (urlPtr) QUrl(); - urlPtr->setEncodedUrl(tmp.toUtf8(), QUrl::TolerantMode); + new (output.geturlptr()) QUrl(tmp); URL_REGISTER(instr->unaryop.output); } diff --git a/src/qml/qml/v8/qv8sequencewrapper_p_p.h b/src/qml/qml/v8/qv8sequencewrapper_p_p.h index eebc40e..4745b7e 100644 --- a/src/qml/qml/v8/qv8sequencewrapper_p_p.h +++ b/src/qml/qml/v8/qv8sequencewrapper_p_p.h @@ -200,9 +200,7 @@ static QString convertQStringToString(QV8Engine *, const QString &v) static QUrl convertV8ValueToUrl(QV8Engine *e, v8::Handle v) { - QUrl u; - u.setEncodedUrl(e->toString(v->ToString()).toUtf8(), QUrl::TolerantMode); - return u; + return QUrl(e->toString(v->ToString())); } static v8::Handle convertUrlToV8Value(QV8Engine *e, const QUrl &v) -- 1.7.2.5