mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:28:16 +02:00
fix for occasional crash when deleting web entity
This commit is contained in:
parent
dc0d0c2d5c
commit
41e0b8732f
3 changed files with 13 additions and 10 deletions
|
@ -41,8 +41,6 @@ Item {
|
||||||
|
|
||||||
property string newUrl: ""
|
property string newUrl: ""
|
||||||
|
|
||||||
profile: desktop.browserProfile
|
|
||||||
|
|
||||||
webChannel.registeredObjects: [eventBridgeWrapper]
|
webChannel.registeredObjects: [eventBridgeWrapper]
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -51,6 +49,8 @@ Item {
|
||||||
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
root.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
|
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
|
||||||
|
@ -96,6 +96,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested:{
|
onNewViewRequested:{
|
||||||
|
// desktop is not defined for web-entities
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
var component = Qt.createComponent("../Browser.qml");
|
var component = Qt.createComponent("../Browser.qml");
|
||||||
var newWindow = component.createObject(desktop);
|
var newWindow = component.createObject(desktop);
|
||||||
|
|
|
@ -81,18 +81,20 @@ RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemI
|
||||||
_touchDevice.setName("RenderableWebEntityItemTouchDevice");
|
_touchDevice.setName("RenderableWebEntityItemTouchDevice");
|
||||||
_touchDevice.setMaximumTouchPoints(4);
|
_touchDevice.setMaximumTouchPoints(4);
|
||||||
|
|
||||||
_webEntityAPIHelper.setPtr(this);
|
_webEntityAPIHelper = new WebEntityAPIHelper;
|
||||||
_webEntityAPIHelper.moveToThread(qApp->thread());
|
_webEntityAPIHelper->setPtr(this);
|
||||||
|
_webEntityAPIHelper->moveToThread(qApp->thread());
|
||||||
|
|
||||||
// forward web events to EntityScriptingInterface
|
// forward web events to EntityScriptingInterface
|
||||||
auto entities = DependencyManager::get<EntityScriptingInterface>();
|
auto entities = DependencyManager::get<EntityScriptingInterface>();
|
||||||
QObject::connect(&_webEntityAPIHelper, &WebEntityAPIHelper::webEventReceived, [=](const QVariant& message) {
|
QObject::connect(_webEntityAPIHelper, &WebEntityAPIHelper::webEventReceived, [=](const QVariant& message) {
|
||||||
emit entities->webEventReceived(entityItemID, message);
|
emit entities->webEventReceived(entityItemID, message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderableWebEntityItem::~RenderableWebEntityItem() {
|
RenderableWebEntityItem::~RenderableWebEntityItem() {
|
||||||
_webEntityAPIHelper.setPtr(nullptr);
|
_webEntityAPIHelper->setPtr(nullptr);
|
||||||
|
_webEntityAPIHelper->deleteLater();
|
||||||
destroyWebSurface();
|
destroyWebSurface();
|
||||||
qDebug() << "Destroyed web entity " << getID();
|
qDebug() << "Destroyed web entity " << getID();
|
||||||
}
|
}
|
||||||
|
@ -113,10 +115,10 @@ bool RenderableWebEntityItem::buildWebSurface(EntityTreeRenderer* renderer) {
|
||||||
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/controls/"));
|
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/controls/"));
|
||||||
_webSurface->load("WebView.qml");
|
_webSurface->load("WebView.qml");
|
||||||
_webSurface->resume();
|
_webSurface->resume();
|
||||||
_webSurface->getRootItem()->setProperty("eventBridge", QVariant::fromValue(&_webEntityAPIHelper));
|
_webSurface->getRootItem()->setProperty("eventBridge", QVariant::fromValue(_webEntityAPIHelper));
|
||||||
_webSurface->getRootItem()->setProperty("url", _sourceUrl);
|
_webSurface->getRootItem()->setProperty("url", _sourceUrl);
|
||||||
_webSurface->getRootContext()->setContextProperty("desktop", QVariant());
|
_webSurface->getRootContext()->setContextProperty("desktop", QVariant());
|
||||||
_webSurface->getRootContext()->setContextProperty("webEntity", &_webEntityAPIHelper);
|
_webSurface->getRootContext()->setContextProperty("webEntity", _webEntityAPIHelper);
|
||||||
_connection = QObject::connect(_webSurface, &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
_connection = QObject::connect(_webSurface, &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
||||||
_texture = textureId;
|
_texture = textureId;
|
||||||
});
|
});
|
||||||
|
@ -402,7 +404,7 @@ void RenderableWebEntityItem::synthesizeKeyPress(QString key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableWebEntityItem::emitScriptEvent(const QVariant& message) {
|
void RenderableWebEntityItem::emitScriptEvent(const QVariant& message) {
|
||||||
_webEntityAPIHelper.emitScriptEvent(message);
|
_webEntityAPIHelper->emitScriptEvent(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableWebEntityItem::setKeyboardRaised(bool raised) {
|
void RenderableWebEntityItem::setKeyboardRaised(bool raised) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
QTouchEvent _lastTouchEvent { QEvent::TouchUpdate };
|
QTouchEvent _lastTouchEvent { QEvent::TouchUpdate };
|
||||||
uint64_t _lastRenderTime{ 0 };
|
uint64_t _lastRenderTime{ 0 };
|
||||||
QTouchDevice _touchDevice;
|
QTouchDevice _touchDevice;
|
||||||
WebEntityAPIHelper _webEntityAPIHelper;
|
WebEntityAPIHelper* _webEntityAPIHelper;
|
||||||
|
|
||||||
QMetaObject::Connection _mousePressConnection;
|
QMetaObject::Connection _mousePressConnection;
|
||||||
QMetaObject::Connection _mouseReleaseConnection;
|
QMetaObject::Connection _mouseReleaseConnection;
|
||||||
|
|
Loading…
Reference in a new issue