mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +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() {
|
void OffscreenUi::hideDesktopWindows() {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (_desktop) {
|
||||||
BLOCKING_INVOKE_METHOD(this, "hideDesktopWindows");
|
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) {
|
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) {
|
bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
|
||||||
QVariant result;
|
if (_desktop) {
|
||||||
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
QVariant result;
|
||||||
Q_RETURN_ARG(QVariant, result),
|
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
||||||
Q_ARG(QVariant, point));
|
Q_RETURN_ARG(QVariant, result),
|
||||||
return result.toBool();
|
Q_ARG(QVariant, point));
|
||||||
|
return result.toBool();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::hide(const QString& name) {
|
void OffscreenUi::hide(const QString& name) {
|
||||||
|
@ -226,12 +231,14 @@ void OffscreenUi::hide(const QString& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffscreenUi::isVisible(const QString& name) {
|
bool OffscreenUi::isVisible(const QString& name) {
|
||||||
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
auto rootItem = getRootItem();
|
||||||
if (item) {
|
if (rootItem) {
|
||||||
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
QQuickItem* item = rootItem->findChild<QQuickItem*>(name);
|
||||||
} else {
|
if (item) {
|
||||||
return false;
|
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageBoxListener : public ModalDialogListener {
|
class MessageBoxListener : public ModalDialogListener {
|
||||||
|
@ -280,12 +287,11 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
|
@ -533,21 +539,21 @@ ModalDialogListener* OffscreenUi::customInputDialogAsync(const Icon icon, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::togglePinned() {
|
void OffscreenUi::togglePinned() {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "togglePinned");
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "togglePinned");
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to toggle window visibility";
|
qWarning() << "Failed to toggle window visibility";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::setPinned(bool pinned) {
|
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) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to set window visibility";
|
qWarning() << "Failed to set window visibility";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::setConstrainToolbarToCenterX(bool constrained) {
|
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) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to set toolbar constraint";
|
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"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
|
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
emit tabletScriptingInterface->tabletNotification();
|
emit tabletScriptingInterface->tabletNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to create message box";
|
qWarning() << "Failed to create message box";
|
||||||
return nullptr;
|
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"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
|
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
|
@ -718,7 +723,7 @@ QObject* OffscreenUi::getRootMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::unfocusWindows() {
|
void OffscreenUi::unfocusWindows() {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
||||||
Q_ASSERT(invokeResult);
|
Q_ASSERT(invokeResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,12 +757,11 @@ QString OffscreenUi::fileDialog(const QVariantMap& properties) {
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -782,12 +786,11 @@ ModalDialogListener* OffscreenUi::fileDialogAsync(const QVariantMap& properties)
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -1003,12 +1006,11 @@ QString OffscreenUi::assetDialog(const QVariantMap& properties) {
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -1034,12 +1036,11 @@ ModalDialogListener *OffscreenUi::assetDialogAsync(const QVariantMap& properties
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
|
|
@ -385,9 +385,11 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
||||||
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
|
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#if !defined(DISABLE_QML)
|
||||||
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
|
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
|
||||||
loadHomeScreen(true);
|
loadHomeScreen(true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//check if running scripts window opened and save it for reopen in Tablet
|
//check if running scripts window opened and save it for reopen in Tablet
|
||||||
if (offscreenUi->isVisible("RunningScripts")) {
|
if (offscreenUi->isVisible("RunningScripts")) {
|
||||||
offscreenUi->hide("RunningScripts");
|
offscreenUi->hide("RunningScripts");
|
||||||
|
|
Loading…
Reference in a new issue