summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-08-26 00:34:09 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-08-26 00:34:09 (GMT)
commit642440f41c5cd4b5f0ee66101b3ca32859293d29 (patch)
tree07c0bbd15d4961d8f62759ca819c92297d41e3e2
parentcf7f81933c593b1459d3afaf9cf8d968c81550cc (diff)
downloadQt-642440f41c5cd4b5f0ee66101b3ca32859293d29.zip
Qt-642440f41c5cd4b5f0ee66101b3ca32859293d29.tar.gz
Qt-642440f41c5cd4b5f0ee66101b3ca32859293d29.tar.bz2
Fix handling of empty strings for URLs
QUrl resolves empty to base, which is not desirable. Preserve emptiness of QUrl. Handle use of empty QUrl with WebView (WebKit doesn't handle empty URLs well either).
-rw-r--r--src/declarative/fx/qfxwebview.cpp8
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2
-rw-r--r--src/declarative/qml/qmlcomponent.cpp2
-rw-r--r--src/declarative/qml/qmlcontext.cpp2
4 files changed, 10 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 4c1629e..04a4eef 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -325,6 +325,12 @@ QUrl QFxWebView::url() const
void QFxWebView::setUrl(const QUrl &url)
{
+ if (url.isEmpty()) {
+ // Make absolute.
+ setUrl(QUrl("about:blank"));
+ return;
+ }
+
Q_D(QFxWebView);
if (url == page()->mainFrame()->url())
return;
@@ -333,7 +339,7 @@ void QFxWebView::setUrl(const QUrl &url)
d->idealwidth>0 ? d->idealwidth : width(),
d->idealheight>0 ? d->idealheight : height()));
- Q_ASSERT(url.isEmpty() || !url.isRelative());
+ Q_ASSERT(!url.isRelative());
if (isComponentComplete())
page()->mainFrame()->load(url);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index bbcc64d..4f96d12 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -365,7 +365,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
case QVariant::Url:
{
instr.type = QmlInstruction::StoreUrl;
- QUrl u = output->url.resolved(QUrl(string));
+ QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string));
instr.storeUrl.propertyIndex = prop.propertyIndex();
instr.storeUrl.value = output->indexForString(u.toString());
}
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 0e141da..e277d91 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -355,7 +355,7 @@ void QmlComponent::loadUrl(const QUrl &url)
d->clear();
- if (url.isRelative())
+ if (url.isRelative() && !url.isEmpty())
d->url = d->engine->baseUrl().resolved(url);
else
d->url = url;
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 61850c3..97ab375 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -422,7 +422,7 @@ void QmlContext::setContextProperty(const QString &name, QObject *value)
QUrl QmlContext::resolvedUrl(const QUrl &src)
{
QmlContext *ctxt = this;
- if (src.isRelative()) {
+ if (src.isRelative() && !src.isEmpty()) {
if (ctxt) {
while(ctxt) {
if(ctxt->d_func()->url.isValid())