summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-01-21 13:34:56 +0100
committerPierre Rossi <pierre.rossi@gmail.com>2013-11-01 13:57:44 +0100
commitfe7c20fbe3e4ada56cd9bc161e1e4376a1bd1019 (patch)
tree813b2e7822cb6fbc1a6786e563f3aec768b30d44
parent70284d66f8bdbc39a9b53030a7624dfd5f7d15ba (diff)
downloadqtwebchannel-fe7c20fbe3e4ada56cd9bc161e1e4376a1bd1019.tar.gz
Clarify connections between webview and webchannel.
We register objects once after the webchannel has initialized. The web view URL on the other hand gets changed via property binding after the web channel's base url is set/modified. This hopefully fixes a race condition between the client-side HTML logic and the registering of objects on the host-side QML app. Change-Id: Ie83f7a415d9005e805a544f25287e51e75fb4dec Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
-rw-r--r--examples/qtobject/qml/qtobject/main.qml4
-rw-r--r--src/qwebchannel.cpp1
-rw-r--r--src/qwebchannel.h1
3 files changed, 4 insertions, 2 deletions
diff --git a/examples/qtobject/qml/qtobject/main.qml b/examples/qtobject/qml/qtobject/main.qml
index 05591a8..2ca26ec 100644
--- a/examples/qtobject/qml/qtobject/main.qml
+++ b/examples/qtobject/qml/qtobject/main.qml
@@ -75,15 +75,15 @@ Rectangle {
}
}
- onBaseUrlChanged: publisher.registerObjects({"testObject1": testObject1, "testObject2": testObject2, "testObject3":testObject3})
+ onInitialized: publisher.registerObjects({"testObject1": testObject1, "testObject2": testObject2, "testObject3":testObject3});
}
width: 480
height: 800
WebView {
+ url: webChannel.baseUrl ? "index.html?webChannelBaseUrl=" + webChannel.baseUrl : "about:blank"
anchors.fill: parent
- url: "index.html?webChannelBaseUrl=" + webChannel.baseUrl
experimental.preferences.developerExtrasEnabled: true
}
}
diff --git a/src/qwebchannel.cpp b/src/qwebchannel.cpp
index ee03cf8..d51dd72 100644
--- a/src/qwebchannel.cpp
+++ b/src/qwebchannel.cpp
@@ -442,6 +442,7 @@ void QWebChannel::setMaxPort(int p)
void QWebChannel::onInitialized()
{
+ emit initialized();
emit baseUrlChanged(d->baseUrl);
}
diff --git a/src/qwebchannel.h b/src/qwebchannel.h
index c3f90d9..b564787 100644
--- a/src/qwebchannel.h
+++ b/src/qwebchannel.h
@@ -106,6 +106,7 @@ signals:
// To be able to access the object from QML, it has to be an explicit QObject* and not a subclass.
void execute(const QString& requestData, QObject* response);
void noPortAvailable();
+ void initialized();
public slots:
void broadcast(const QString& id, const QString& data);