mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
Fix QQuickItem pointers
This commit is contained in:
parent
1e8d032ea3
commit
ae36233ff9
1 changed files with 30 additions and 20 deletions
|
@ -167,16 +167,18 @@ void QmlWindowClass::qmlToScript(const QVariant& message) {
|
|||
|
||||
void QmlWindowClass::sendToQml(const QVariant& message) {
|
||||
// Forward messages received from the script on to QML
|
||||
if (asQuickItem()) {
|
||||
QMetaObject::invokeMethod(asQuickItem(), "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
QMetaObject::invokeMethod(quickItem, "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::sendToQml: asQuickItem() returned NULL";
|
||||
}
|
||||
}
|
||||
|
||||
void QmlWindowClass::clearDebugWindow() {
|
||||
if (asQuickItem()) {
|
||||
QMetaObject::invokeMethod(asQuickItem(), "clearDebugWindow", Qt::QueuedConnection);
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
QMetaObject::invokeMethod(quickItem, "clearDebugWindow", Qt::QueuedConnection);
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::clearDebugWindow: asQuickItem() returned NULL";
|
||||
}
|
||||
|
@ -200,14 +202,16 @@ void QmlWindowClass::emitWebEvent(const QVariant& webMessage) {
|
|||
const QString LOWER_KEYBOARD = "_LOWER_KEYBOARD";
|
||||
QString messageString = webMessage.type() == QVariant::String ? webMessage.toString() : "";
|
||||
if (messageString.left(RAISE_KEYBOARD.length()) == RAISE_KEYBOARD) {
|
||||
if (asQuickItem()) {
|
||||
setKeyboardRaised(asQuickItem(), true, messageString == RAISE_KEYBOARD_NUMERIC);
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
setKeyboardRaised(quickItem, true, messageString == RAISE_KEYBOARD_NUMERIC);
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::emitWebEvent: asQuickItem() returned NULL";
|
||||
}
|
||||
} else if (messageString == LOWER_KEYBOARD) {
|
||||
if (asQuickItem()) {
|
||||
setKeyboardRaised(asQuickItem(), false);
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
setKeyboardRaised(quickItem, false);
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::emitWebEvent: asQuickItem() returned NULL";
|
||||
}
|
||||
|
@ -270,8 +274,9 @@ bool QmlWindowClass::isVisible() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
return asQuickItem()->isVisible();
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
return quickItem->isVisible();
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::isVisible: asQuickItem() returned NULL";
|
||||
}
|
||||
|
@ -288,8 +293,9 @@ glm::vec2 QmlWindowClass::getPosition() {
|
|||
return {};
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
return toGlm(asQuickItem()->position());
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
return toGlm(quickItem->position());
|
||||
} else {
|
||||
qDebug() << "QmlWindowClass::getPosition: asQuickItem() returned NULL";
|
||||
return glm::vec2(0.0f, 0.0f);
|
||||
|
@ -302,8 +308,9 @@ void QmlWindowClass::setPosition(const glm::vec2& position) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
asQuickItem()->setPosition(QPointF(position.x, position.y));
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
quickItem->setPosition(QPointF(position.x, position.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,8 +348,9 @@ void QmlWindowClass::setSize(const glm::vec2& size) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
asQuickItem()->setSize(QSizeF(size.x, size.y));
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
quickItem->setSize(QSizeF(size.x, size.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,8 +364,9 @@ void QmlWindowClass::setTitle(const QString& title) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
asQuickItem()->setProperty(TITLE_PROPERTY, title);
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
quickItem->setProperty(TITLE_PROPERTY, title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +396,8 @@ void QmlWindowClass::raise() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (asQuickItem()) {
|
||||
QMetaObject::invokeMethod(asQuickItem(), "raise", Qt::DirectConnection);
|
||||
QQuickItem *quickItem = asQuickItem();
|
||||
if (quickItem) {
|
||||
QMetaObject::invokeMethod(quickItem, "raise", Qt::DirectConnection);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue