mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 12:17:31 +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;
|
||||
}
|
||||
|
||||
OffscreenQmlSurface::~OffscreenQmlSurface() {
|
||||
clearFocusItem();
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::clearFocusItem() {
|
||||
if (_currentFocusItem) {
|
||||
disconnect(_currentFocusItem, &QObject::destroyed, this, &OffscreenQmlSurface::focusDestroyed);
|
||||
}
|
||||
_currentFocusItem = nullptr;
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
|
||||
Parent::initializeEngine(engine);
|
||||
new QQmlFileSelector(engine);
|
||||
|
@ -545,17 +556,15 @@ bool OffscreenQmlSurface::handlePointerEvent(const PointerEvent& event, class QT
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::focusDestroyed(QObject* obj) {
|
||||
if (_currentFocusItem) {
|
||||
disconnect(_currentFocusItem, &QObject::destroyed, this, &OffscreenQmlSurface::focusDestroyed);
|
||||
}
|
||||
_currentFocusItem = nullptr;
|
||||
clearFocusItem();
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::onFocusObjectChanged(QObject* object) {
|
||||
clearFocusItem();
|
||||
|
||||
QQuickItem* item = static_cast<QQuickItem*>(object);
|
||||
if (!item) {
|
||||
setFocusText(false);
|
||||
_currentFocusItem = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -563,10 +572,6 @@ void OffscreenQmlSurface::onFocusObjectChanged(QObject* object) {
|
|||
qApp->sendEvent(object, &query);
|
||||
setFocusText(query.value(Qt::ImEnabled).toBool());
|
||||
|
||||
if (_currentFocusItem) {
|
||||
disconnect(_currentFocusItem, &QObject::destroyed, this, 0);
|
||||
}
|
||||
|
||||
// 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.
|
||||
const char* READ_ONLY_PROPERTY = "readOnly";
|
||||
|
|
|
@ -22,7 +22,8 @@ class OffscreenQmlSurface : public hifi::qml::OffscreenSurface {
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
||||
public:
|
||||
|
||||
~OffscreenQmlSurface();
|
||||
|
||||
static void addWhitelistContextHandler(const std::initializer_list<QUrl>& urls, const QmlContextCallback& callback);
|
||||
static void addWhitelistContextHandler(const QUrl& url, const QmlContextCallback& callback) { addWhitelistContextHandler({ { url } }, callback); };
|
||||
|
||||
|
@ -58,6 +59,7 @@ public slots:
|
|||
void sendToQml(const QVariant& message);
|
||||
|
||||
protected:
|
||||
void clearFocusItem();
|
||||
void setFocusText(bool newFocusText);
|
||||
void initializeEngine(QQmlEngine* engine) override;
|
||||
void onRootContextCreated(QQmlContext* qmlContext) override;
|
||||
|
|
Loading…
Reference in a new issue