mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:16:45 +02:00
Merge pull request #10193 from sethalves/fix-dont-delete-tablet-qobject
change handling of life-time of TabletProxy QObjects
This commit is contained in:
commit
3a603e7ced
2 changed files with 5 additions and 5 deletions
|
@ -49,13 +49,14 @@ QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
||||||
auto iter = _tabletProxies.find(tabletId);
|
auto iter = _tabletProxies.find(tabletId);
|
||||||
if (iter != _tabletProxies.end()) {
|
if (iter != _tabletProxies.end()) {
|
||||||
// tablet already exists, just return it.
|
// tablet already exists, just return it.
|
||||||
return iter->second.data();
|
return iter->second;
|
||||||
} else {
|
} else {
|
||||||
// allocate a new tablet, add it to the map then return it.
|
// 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;
|
_tabletProxies[tabletId] = tabletProxy;
|
||||||
tabletProxy->setToolbarMode(_toolbarMode);
|
tabletProxy->setToolbarMode(_toolbarMode);
|
||||||
return tabletProxy.data();
|
return tabletProxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +177,6 @@ class TabletRootWindow : public QmlWindowClass {
|
||||||
};
|
};
|
||||||
|
|
||||||
TabletProxy::TabletProxy(QString name) : _name(name) {
|
TabletProxy::TabletProxy(QString name) : _name(name) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::setToolbarMode(bool toolbarMode) {
|
void TabletProxy::setToolbarMode(bool toolbarMode) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::mutex _mutex;
|
std::mutex _mutex;
|
||||||
std::map<QString, QSharedPointer<TabletProxy>> _tabletProxies;
|
std::map<QString, TabletProxy*> _tabletProxies;
|
||||||
QObject* _toolbarScriptingInterface { nullptr };
|
QObject* _toolbarScriptingInterface { nullptr };
|
||||||
bool _toolbarMode { false };
|
bool _toolbarMode { false };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue