mirror of
https://github.com/overte-org/overte.git
synced 2025-06-15 14:59:21 +02:00
Prevent crash on switching to 3D display twice
This commit is contained in:
parent
7cb2bff4c5
commit
fb995bebf1
1 changed files with 7 additions and 3 deletions
|
@ -37,15 +37,17 @@ public:
|
||||||
qmlObject->setObjectName(uuid.toString());
|
qmlObject->setObjectName(uuid.toString());
|
||||||
// Make sure we can find it again in the future
|
// Make sure we can find it again in the future
|
||||||
updateQmlItemFromAction();
|
updateQmlItemFromAction();
|
||||||
auto connection = QObject::connect(action, &QAction::changed, [=] {
|
_changedConnection = QObject::connect(action, &QAction::changed, [=] {
|
||||||
updateQmlItemFromAction();
|
updateQmlItemFromAction();
|
||||||
});
|
});
|
||||||
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=] {
|
_shutdownConnection = QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=] {
|
||||||
QObject::disconnect(connection);
|
QObject::disconnect(_changedConnection);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
~MenuUserData() {
|
~MenuUserData() {
|
||||||
|
QObject::disconnect(_changedConnection);
|
||||||
|
QObject::disconnect(_shutdownConnection);
|
||||||
_action->setUserData(USER_DATA_ID, nullptr);
|
_action->setUserData(USER_DATA_ID, nullptr);
|
||||||
_qml->setUserData(USER_DATA_ID, nullptr);
|
_qml->setUserData(USER_DATA_ID, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -104,6 +106,8 @@ public:
|
||||||
private:
|
private:
|
||||||
MenuUserData(const MenuUserData&);
|
MenuUserData(const MenuUserData&);
|
||||||
|
|
||||||
|
QMetaObject::Connection _shutdownConnection;
|
||||||
|
QMetaObject::Connection _changedConnection;
|
||||||
QAction* _action { nullptr };
|
QAction* _action { nullptr };
|
||||||
QObject* _qml { nullptr };
|
QObject* _qml { nullptr };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue