change handling of life-time of TabletProxy QObjects

This commit is contained in:
Seth Alves 2017-04-11 10:56:47 -07:00
parent b7daf8c80b
commit 077a4fe4ae
2 changed files with 5 additions and 5 deletions

View file

@ -49,13 +49,14 @@ QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
auto iter = _tabletProxies.find(tabletId);
if (iter != _tabletProxies.end()) {
// tablet already exists, just return it.
return iter->second.data();
return iter->second;
} else {
// allocate a new tablet, add it to the map then return it.
auto tabletProxy = QSharedPointer<TabletProxy>(new TabletProxy(tabletId));
auto tabletProxy = new TabletProxy(tabletId);
tabletProxy->setParent(this);
_tabletProxies[tabletId] = tabletProxy;
tabletProxy->setToolbarMode(_toolbarMode);
return tabletProxy.data();
return tabletProxy;
}
}
@ -176,7 +177,6 @@ class TabletRootWindow : public QmlWindowClass {
};
TabletProxy::TabletProxy(QString name) : _name(name) {
}
void TabletProxy::setToolbarMode(bool toolbarMode) {

View file

@ -70,7 +70,7 @@ private:
protected:
std::mutex _mutex;
std::map<QString, QSharedPointer<TabletProxy>> _tabletProxies;
std::map<QString, TabletProxy*> _tabletProxies;
QObject* _toolbarScriptingInterface { nullptr };
bool _toolbarMode { false };
};