* The TabletScriptingInterface destructor is invoked on app shutdown after the logging system has been destroyed. To avoid this I removed the destructor. The log was only for debug purposes anyway. * Removed calls to setProperty() these calls are not thread safe and were causing asserts during debug. Instead of getting and setting the property we maintain the TabletProxy state using an enum.
Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -21,10 +21,6 @@ TabletScriptingInterface::TabletScriptingInterface() { · 20 unmodified lines | ||
| 21 | 21 | qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect"); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | −TabletScriptingInterface::~TabletScriptingInterface() { | |
| 25 | − qDebug() << "Shutting down TabletScriptingInterface"; | |
| 26 | −} | |
| 27 | − | |
| 28 | 24 | QObject* TabletScriptingInterface::getTablet(const QString& tabletId) { |
| 29 | 25 | |
| 30 | 26 | std::lock_guard<std::mutex> guard(_mutex); |
| @@ -95,38 +91,40 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr · 64 unmodified lines | ||
| 95 | 91 | gotoHomeScreen(); |
| 96 | 92 | } else { |
| 97 | 93 | removeButtonsFromHomeScreen(); |
| 94 | + _state = State::Uninitialized; | |
| 98 | 95 | } |
| 99 | 96 | } |
| 100 | 97 | |
| 101 | 98 | void TabletProxy::gotoMenuScreen() { |
| 102 | 99 | if (_qmlTabletRoot) { |
| 103 | − _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, VRMENU_SOURCE_URL); | |
| 104 | − auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader"); | |
| 105 | − QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToMenuScreen())); | |
| 106 | − QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL))); | |
| 100 | + if (_state != State::Menu) { | |
| 101 | + auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader"); | |
| 102 | + QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToMenuScreen())); | |
| 103 | + QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL))); | |
| 104 | + _state = State::Menu; | |
| 105 | + } | |
| 107 | 106 | } |
| 108 | 107 | } |
| 109 | 108 | |
| 110 | 109 | void TabletProxy::gotoHomeScreen() { |
| 111 | 110 | if (_qmlTabletRoot) { |
| 112 | − QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString(); | |
| 113 | − if (tabletSource != TABLET_SOURCE_URL) { | |
| 114 | − _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, TABLET_SOURCE_URL); | |
| 111 | + if (_state != State::Home) { | |
| 115 | 112 | auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader"); |
| 116 | 113 | QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen())); |
| 117 | 114 | QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL))); |
| 115 | + _state = State::Home; | |
| 118 | 116 | } |
| 119 | 117 | } |
| 120 | 118 | } |
| 121 | 119 | |
| 122 | 120 | void TabletProxy::gotoWebScreen(const QString& url) { |
| 123 | 121 | if (_qmlTabletRoot) { |
| 124 | − removeButtonsFromHomeScreen(); | |
| 125 | − QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString(); | |
| 126 | − if (tabletSource != WEB_VIEW_SOURCE_URL) { | |
| 127 | − _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, WEB_VIEW_SOURCE_URL); | |
| 122 | + if (_state == State::Home) { | |
| 123 | + removeButtonsFromHomeScreen(); | |
| 124 | + } | |
| 125 | + if (_state != State::Web) { | |
| 128 | 126 | QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL))); |
| 129 | − // TABLET_UI_HACK: TODO: addEventBridge to tablet.... | |
| 127 | + _state = State::Web; | |
| 130 | 128 | } |
| 131 | 129 | QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url))); |
| 132 | 130 | } |