History

Fixes for qt asserts in debug

* 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.

Anthony J. Thibault committed 9 years ago

Commit cf138eb1 parent 0746d382 files · +17 −17Browse files

Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/TabletScriptingInterface.cpp+14−16
@@ -21,10 +21,6 @@ TabletScriptingInterface::TabletScriptingInterface() { · 20 unmodified lines
21 qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");21 qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
22}22}
23 23
24TabletScriptingInterface::~TabletScriptingInterface() {
25 qDebug() << "Shutting down TabletScriptingInterface";
26}
27
28QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {24QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
29 25
30 std::lock_guard<std::mutex> guard(_mutex);26 std::lock_guard<std::mutex> guard(_mutex);
@@ -95,38 +91,40 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr · 64 unmodified lines
95 gotoHomeScreen();91 gotoHomeScreen();
96 } else {92 } else {
97 removeButtonsFromHomeScreen();93 removeButtonsFromHomeScreen();
94 _state = State::Uninitialized;
98 }95 }
99}96}
100 97
101void TabletProxy::gotoMenuScreen() {98void TabletProxy::gotoMenuScreen() {
102 if (_qmlTabletRoot) {99 if (_qmlTabletRoot) {
103 _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, VRMENU_SOURCE_URL);100 if (_state != State::Menu) {
104 auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");101 auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
105 QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToMenuScreen()));102 QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToMenuScreen()));
106 QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));103 QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
104 _state = State::Menu;
105 }
107 }106 }
108}107}
109 108
110void TabletProxy::gotoHomeScreen() {109void TabletProxy::gotoHomeScreen() {
111 if (_qmlTabletRoot) {110 if (_qmlTabletRoot) {
112 QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString();111 if (_state != State::Home) {
113 if (tabletSource != TABLET_SOURCE_URL) {
114 _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, TABLET_SOURCE_URL);
115 auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");112 auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
116 QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));113 QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
117 QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL)));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
122void TabletProxy::gotoWebScreen(const QString& url) {120void TabletProxy::gotoWebScreen(const QString& url) {
123 if (_qmlTabletRoot) {121 if (_qmlTabletRoot) {
124 removeButtonsFromHomeScreen();122 if (_state == State::Home) {
125 QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString();123 removeButtonsFromHomeScreen();
126 if (tabletSource != WEB_VIEW_SOURCE_URL) {124 }
127 _qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, WEB_VIEW_SOURCE_URL);125 if (_state != State::Web) {
128 QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));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 QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)));129 QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)));
132 }130 }