Make sure Tablet will be shown with opened running scripts dialog. Fixed potential stack corruption

This commit is contained in:
vladest 2017-07-31 16:45:21 +02:00
parent 751f12df89
commit e30e0b1a5f
2 changed files with 26 additions and 17 deletions

View file

@ -202,5 +202,11 @@ Item {
width: 480 width: 480
height: 706 height: 706
function setShown(value) {} function setShown(value) {
if (value === true) {
HMD.openTablet()
} else {
HMD.closeTablet()
}
}
} }

View file

@ -245,20 +245,6 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
loadHomeScreen(true); loadHomeScreen(true);
emit screenChanged(QVariant("Home"), QVariant(TABLET_SOURCE_URL)); emit screenChanged(QVariant("Home"), QVariant(TABLET_SOURCE_URL));
//connect to Tablet shown signal to open running scripts
if (_showRunningScripts) {
QMetaObject::invokeMethod(qApp, "toggleTabletUI", Q_ARG(bool, true));
//qApp->toggleTabletUI(true);
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = connect(this, &TabletProxy::tabletShownChanged, this, [this, conn] {
QObject::disconnect(*conn);
if (_tabletShown && _showRunningScripts) {
_showRunningScripts = false;
pushOntoStack("../../hifi/dialogs/TabletRunningScripts.qml");
}
});
}
} }
@ -384,9 +370,26 @@ void TabletProxy::setQmlTabletRoot(OffscreenQmlSurface* qmlOffscreenSurface) {
}); });
if (_initialScreen) { if (_initialScreen) {
pushOntoStack(_initialPath); if (!_showRunningScripts) {
pushOntoStack(_initialPath);
}
_initialScreen = false; _initialScreen = false;
} }
if (_showRunningScripts) {
_showRunningScripts = false;
//connect to Tablet shown signal to open running scripts
//we cant just call pushOnStack here since RunningScripts draws incorrectly
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = connect(this, &TabletProxy::tabletShownChanged, this, [this, conn] {
QObject::disconnect(*conn); //not needed anymore, disconnect
if (_tabletShown) {
pushOntoStack("../../hifi/dialogs/TabletRunningScripts.qml");
}
});
//show Tablet. Make sure, setShown implemented in TabletRoot.qml
QMetaObject::invokeMethod(_qmlTabletRoot, "setShown", Q_ARG(const QVariant&, QVariant(true)));
}
} else { } else {
removeButtonsFromHomeScreen(); removeButtonsFromHomeScreen();
_state = State::Uninitialized; _state = State::Uninitialized;
@ -523,7 +526,7 @@ bool TabletProxy::pushOntoStack(const QVariant& path) {
qCDebug(uiLogging) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null"; qCDebug(uiLogging) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null";
} }
return root; return (root != nullptr);
} }
void TabletProxy::popFromStack() { void TabletProxy::popFromStack() {