Merge pull request #6844 from jherico/web_crash

Fix JS web window crash caused by race condition
This commit is contained in:
Brad Hefta-Gaub 2016-01-15 16:44:51 -08:00
commit 8ffd30f89a

View file

@ -42,19 +42,15 @@ QmlWebWindowClass::QmlWebWindowClass(QObject* qmlWindow) : QmlWindowClass(qmlWin
void QmlWebWindowClass::handleNavigation(const QString& url) { void QmlWebWindowClass::handleNavigation(const QString& url) {
} }
QString QmlWebWindowClass::getURL() const { QString QmlWebWindowClass::getURL() const {
if (QThread::currentThread() != thread()) { QVariant result = DependencyManager::get<OffscreenUi>()->returnFromUiThread([&]()->QVariant {
QString result; return _qmlWindow->property(URL_PROPERTY);
QMetaObject::invokeMethod(const_cast<QmlWebWindowClass*>(this), "getURL", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, result)); });
return result; return result.toString();
}
return _qmlWindow->property(URL_PROPERTY).toString();
} }
void QmlWebWindowClass::setURL(const QString& urlString) { void QmlWebWindowClass::setURL(const QString& urlString) {
if (QThread::currentThread() != thread()) { DependencyManager::get<OffscreenUi>()->executeOnUiThread([=] {
QMetaObject::invokeMethod(this, "setURL", Qt::QueuedConnection, Q_ARG(QString, urlString)); _qmlWindow->setProperty(URL_PROPERTY, urlString);
} });
_qmlWindow->setProperty(URL_PROPERTY, urlString); }
}