mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +02:00
Fix bad virtual cast on qml surface destruction
This commit is contained in:
parent
2662dc9b4e
commit
4db83230ce
2 changed files with 17 additions and 10 deletions
|
@ -223,6 +223,17 @@ void AudioHandler::run() {
|
||||||
qDebug() << "QML Audio changed to " << _newTargetDevice;
|
qDebug() << "QML Audio changed to " << _newTargetDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OffscreenQmlSurface::~OffscreenQmlSurface() {
|
||||||
|
clearFocusItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OffscreenQmlSurface::clearFocusItem() {
|
||||||
|
if (_currentFocusItem) {
|
||||||
|
disconnect(_currentFocusItem, &QObject::destroyed, this, &OffscreenQmlSurface::focusDestroyed);
|
||||||
|
}
|
||||||
|
_currentFocusItem = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
|
void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
|
||||||
Parent::initializeEngine(engine);
|
Parent::initializeEngine(engine);
|
||||||
new QQmlFileSelector(engine);
|
new QQmlFileSelector(engine);
|
||||||
|
@ -545,17 +556,15 @@ bool OffscreenQmlSurface::handlePointerEvent(const PointerEvent& event, class QT
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::focusDestroyed(QObject* obj) {
|
void OffscreenQmlSurface::focusDestroyed(QObject* obj) {
|
||||||
if (_currentFocusItem) {
|
clearFocusItem();
|
||||||
disconnect(_currentFocusItem, &QObject::destroyed, this, &OffscreenQmlSurface::focusDestroyed);
|
|
||||||
}
|
|
||||||
_currentFocusItem = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::onFocusObjectChanged(QObject* object) {
|
void OffscreenQmlSurface::onFocusObjectChanged(QObject* object) {
|
||||||
|
clearFocusItem();
|
||||||
|
|
||||||
QQuickItem* item = static_cast<QQuickItem*>(object);
|
QQuickItem* item = static_cast<QQuickItem*>(object);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
setFocusText(false);
|
setFocusText(false);
|
||||||
_currentFocusItem = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,10 +572,6 @@ void OffscreenQmlSurface::onFocusObjectChanged(QObject* object) {
|
||||||
qApp->sendEvent(object, &query);
|
qApp->sendEvent(object, &query);
|
||||||
setFocusText(query.value(Qt::ImEnabled).toBool());
|
setFocusText(query.value(Qt::ImEnabled).toBool());
|
||||||
|
|
||||||
if (_currentFocusItem) {
|
|
||||||
disconnect(_currentFocusItem, &QObject::destroyed, this, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raise and lower keyboard for QML text fields.
|
// Raise and lower keyboard for QML text fields.
|
||||||
// HTML text fields are handled in emitWebEvent() methods - testing READ_ONLY_PROPERTY prevents action for HTML files.
|
// HTML text fields are handled in emitWebEvent() methods - testing READ_ONLY_PROPERTY prevents action for HTML files.
|
||||||
const char* READ_ONLY_PROPERTY = "readOnly";
|
const char* READ_ONLY_PROPERTY = "readOnly";
|
||||||
|
|
|
@ -22,7 +22,8 @@ class OffscreenQmlSurface : public hifi::qml::OffscreenSurface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
||||||
public:
|
public:
|
||||||
|
~OffscreenQmlSurface();
|
||||||
|
|
||||||
static void addWhitelistContextHandler(const std::initializer_list<QUrl>& urls, const QmlContextCallback& callback);
|
static void addWhitelistContextHandler(const std::initializer_list<QUrl>& urls, const QmlContextCallback& callback);
|
||||||
static void addWhitelistContextHandler(const QUrl& url, const QmlContextCallback& callback) { addWhitelistContextHandler({ { url } }, callback); };
|
static void addWhitelistContextHandler(const QUrl& url, const QmlContextCallback& callback) { addWhitelistContextHandler({ { url } }, callback); };
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ public slots:
|
||||||
void sendToQml(const QVariant& message);
|
void sendToQml(const QVariant& message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void clearFocusItem();
|
||||||
void setFocusText(bool newFocusText);
|
void setFocusText(bool newFocusText);
|
||||||
void initializeEngine(QQmlEngine* engine) override;
|
void initializeEngine(QQmlEngine* engine) override;
|
||||||
void onRootContextCreated(QQmlContext* qmlContext) override;
|
void onRootContextCreated(QQmlContext* qmlContext) override;
|
||||||
|
|
Loading…
Reference in a new issue