mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
Merge pull request #6844 from jherico/web_crash
Fix JS web window crash caused by race condition
This commit is contained in:
commit
8ffd30f89a
1 changed files with 9 additions and 13 deletions
|
@ -42,19 +42,15 @@ QmlWebWindowClass::QmlWebWindowClass(QObject* qmlWindow) : QmlWindowClass(qmlWin
|
|||
void QmlWebWindowClass::handleNavigation(const QString& url) {
|
||||
}
|
||||
|
||||
QString QmlWebWindowClass::getURL() const {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QString result;
|
||||
QMetaObject::invokeMethod(const_cast<QmlWebWindowClass*>(this), "getURL", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
return _qmlWindow->property(URL_PROPERTY).toString();
|
||||
QString QmlWebWindowClass::getURL() const {
|
||||
QVariant result = DependencyManager::get<OffscreenUi>()->returnFromUiThread([&]()->QVariant {
|
||||
return _qmlWindow->property(URL_PROPERTY);
|
||||
});
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
void QmlWebWindowClass::setURL(const QString& urlString) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setURL", Qt::QueuedConnection, Q_ARG(QString, urlString));
|
||||
}
|
||||
_qmlWindow->setProperty(URL_PROPERTY, urlString);
|
||||
}
|
||||
DependencyManager::get<OffscreenUi>()->executeOnUiThread([=] {
|
||||
_qmlWindow->setProperty(URL_PROPERTY, urlString);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue