mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
fix crashes when running with qml disabled in VR
This commit is contained in:
parent
06b1a8e17c
commit
4bf952260f
2 changed files with 41 additions and 38 deletions
|
@ -189,10 +189,12 @@ void OffscreenUi::show(const QUrl& url, const QString& name, std::function<void(
|
|||
}
|
||||
|
||||
void OffscreenUi::hideDesktopWindows() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
BLOCKING_INVOKE_METHOD(this, "hideDesktopWindows");
|
||||
if (_desktop) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
BLOCKING_INVOKE_METHOD(this, "hideDesktopWindows");
|
||||
}
|
||||
QMetaObject::invokeMethod(_desktop, "hideDesktopWindows");
|
||||
}
|
||||
QMetaObject::invokeMethod(_desktop, "hideDesktopWindows");
|
||||
}
|
||||
|
||||
void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f) {
|
||||
|
@ -208,11 +210,14 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<voi
|
|||
}
|
||||
|
||||
bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
|
||||
QVariant result;
|
||||
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, point));
|
||||
return result.toBool();
|
||||
if (_desktop) {
|
||||
QVariant result;
|
||||
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, point));
|
||||
return result.toBool();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OffscreenUi::hide(const QString& name) {
|
||||
|
@ -226,12 +231,14 @@ void OffscreenUi::hide(const QString& name) {
|
|||
}
|
||||
|
||||
bool OffscreenUi::isVisible(const QString& name) {
|
||||
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
||||
if (item) {
|
||||
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
||||
} else {
|
||||
return false;
|
||||
auto rootItem = getRootItem();
|
||||
if (rootItem) {
|
||||
QQuickItem* item = rootItem->findChild<QQuickItem*>(name);
|
||||
if (item) {
|
||||
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class MessageBoxListener : public ModalDialogListener {
|
||||
|
@ -280,12 +287,11 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const
|
|||
bool invokeResult;
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
|
@ -533,21 +539,21 @@ ModalDialogListener* OffscreenUi::customInputDialogAsync(const Icon icon, const
|
|||
}
|
||||
|
||||
void OffscreenUi::togglePinned() {
|
||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "togglePinned");
|
||||
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "togglePinned");
|
||||
if (!invokeResult) {
|
||||
qWarning() << "Failed to toggle window visibility";
|
||||
}
|
||||
}
|
||||
|
||||
void OffscreenUi::setPinned(bool pinned) {
|
||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "setPinned", Q_ARG(QVariant, pinned));
|
||||
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "setPinned", Q_ARG(QVariant, pinned));
|
||||
if (!invokeResult) {
|
||||
qWarning() << "Failed to set window visibility";
|
||||
}
|
||||
}
|
||||
|
||||
void OffscreenUi::setConstrainToolbarToCenterX(bool constrained) {
|
||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "setConstrainToolbarToCenterX", Q_ARG(QVariant, constrained));
|
||||
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "setConstrainToolbarToCenterX", Q_ARG(QVariant, constrained));
|
||||
if (!invokeResult) {
|
||||
qWarning() << "Failed to set toolbar constraint";
|
||||
}
|
||||
|
@ -575,17 +581,17 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title
|
|||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
|
||||
bool invokeResult;
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
emit tabletScriptingInterface->tabletNotification();
|
||||
}
|
||||
|
||||
if (!invokeResult) {
|
||||
qWarning() << "Failed to create message box";
|
||||
return nullptr;
|
||||
|
@ -603,12 +609,11 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString&
|
|||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
|
||||
bool invokeResult;
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||
|
@ -718,7 +723,7 @@ QObject* OffscreenUi::getRootMenu() {
|
|||
}
|
||||
|
||||
void OffscreenUi::unfocusWindows() {
|
||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
||||
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
||||
Q_ASSERT(invokeResult);
|
||||
}
|
||||
|
||||
|
@ -752,12 +757,11 @@ QString OffscreenUi::fileDialog(const QVariantMap& properties) {
|
|||
bool invokeResult;
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
|
@ -782,12 +786,11 @@ ModalDialogListener* OffscreenUi::fileDialogAsync(const QVariantMap& properties)
|
|||
bool invokeResult;
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
|
@ -1003,12 +1006,11 @@ QString OffscreenUi::assetDialog(const QVariantMap& properties) {
|
|||
bool invokeResult;
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
|
@ -1034,12 +1036,11 @@ ModalDialogListener *OffscreenUi::assetDialogAsync(const QVariantMap& properties
|
|||
bool invokeResult;
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->getToolbarMode() && _desktop) {
|
||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
} else {
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||
|
|
|
@ -385,9 +385,11 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
|||
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
|
||||
#endif
|
||||
} else {
|
||||
#if !defined(DISABLE_QML)
|
||||
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
|
||||
loadHomeScreen(true);
|
||||
}
|
||||
#endif
|
||||
//check if running scripts window opened and save it for reopen in Tablet
|
||||
if (offscreenUi->isVisible("RunningScripts")) {
|
||||
offscreenUi->hide("RunningScripts");
|
||||
|
|
Loading…
Reference in a new issue