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
2121 qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
2222 }
2323
24−TabletScriptingInterface::~TabletScriptingInterface() {
25− qDebug() << "Shutting down TabletScriptingInterface";
26−}
27−
2824 QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
2925
3026 std::lock_guard<std::mutex> guard(_mutex);
@@ -95,38 +91,40 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr · 64 unmodified lines
9591 gotoHomeScreen();
9692 } else {
9793 removeButtonsFromHomeScreen();
94+ _state = State::Uninitialized;
9895 }
9996 }
10097
10198 void TabletProxy::gotoMenuScreen() {
10299 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+ }
107106 }
108107 }
109108
110109 void TabletProxy::gotoHomeScreen() {
111110 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) {
115112 auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
116113 QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
117114 QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL)));
115+ _state = State::Home;
118116 }
119117 }
120118 }
121119
122120 void TabletProxy::gotoWebScreen(const QString& url) {
123121 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) {
128126 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;
130128 }
131129 QMetaObject::invokeMethod(_qmlTabletRoot, "loadWebUrl", Q_ARG(const QVariant&, QVariant(url)));
132130 }