trying to fix web surfaces??

This commit is contained in:
SamGondelman 2019-01-28 18:29:09 -08:00
parent 0d1e4bed66
commit 7b88efa42c
4 changed files with 11 additions and 16 deletions

View file

@ -2332,7 +2332,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// Fix for crash in QtWebEngineCore when rapidly switching domains // Fix for crash in QtWebEngineCore when rapidly switching domains
// Call stop on the QWebEngineView before destroying OffscreenQMLSurface. // Call stop on the QWebEngineView before destroying OffscreenQMLSurface.
if (rootItem) { if (rootItem && !cachedWebSurface) {
// stop loading // stop loading
QMetaObject::invokeMethod(rootItem, "stop"); QMetaObject::invokeMethod(rootItem, "stop");
} }

View file

@ -189,13 +189,13 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
}); });
if (urlChanged) { if (urlChanged) {
if (!_loading && (newContentType != ContentType::HtmlContent || currentContentType != ContentType::HtmlContent)) {
destroyWebSurface();
}
withWriteLock([&] { withWriteLock([&] {
_contentType = newContentType; _contentType = newContentType;
}); });
if (newContentType != ContentType::HtmlContent || currentContentType != ContentType::HtmlContent) {
destroyWebSurface();
}
} }
} }
@ -214,10 +214,12 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
// This work must be done on the main thread // This work must be done on the main thread
if (!_webSurface) { if (!_webSurface) {
buildWebSurface(entity, newSourceURL); buildWebSurface(entity, newSourceURL);
_loading = true;
} }
if (_webSurface && _webSurface->getRootItem()) { if (_webSurface) {
if (_webSurface->getRootItem()) { if (_webSurface->getRootItem()) {
_loading = false;
if (_contentType == ContentType::HtmlContent && urlChanged) { if (_contentType == ContentType::HtmlContent && urlChanged) {
_webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL); _webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL);
_sourceURL = newSourceURL; _sourceURL = newSourceURL;

View file

@ -77,6 +77,7 @@ private:
}; };
static ContentType getContentType(const QString& urlString); static ContentType getContentType(const QString& urlString);
ContentType _contentType { ContentType::NoContent }; ContentType _contentType { ContentType::NoContent };
bool _loading { false };
QSharedPointer<OffscreenQmlSurface> _webSurface { nullptr }; QSharedPointer<OffscreenQmlSurface> _webSurface { nullptr };
bool _cachedWebSurface { false }; bool _cachedWebSurface { false };

View file

@ -232,15 +232,7 @@ float WebEntityItem::getAlpha() const {
void WebEntityItem::setSourceUrl(const QString& value) { void WebEntityItem::setSourceUrl(const QString& value) {
withWriteLock([&] { withWriteLock([&] {
if (_sourceUrl != value) { _sourceUrl = value;
auto newURL = QUrl::fromUserInput(value);
if (newURL.isValid()) {
_sourceUrl = newURL.toDisplayString();
} else {
qCDebug(entities) << "Clearing web entity source URL since" << value << "cannot be parsed to a valid URL.";
}
}
}); });
} }
@ -270,7 +262,7 @@ void WebEntityItem::setScriptURL(const QString& value) {
if (newURL.isValid()) { if (newURL.isValid()) {
_scriptURL = newURL.toDisplayString(); _scriptURL = newURL.toDisplayString();
} else { } else {
qCDebug(entities) << "Clearing web entity source URL since" << value << "cannot be parsed to a valid URL."; qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL.";
} }
} }
}); });