mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #10382 from jherico/3d_crash
Prevent crash on switching to 3D display twice
This commit is contained in:
commit
f4df1a3a05
1 changed files with 7 additions and 3 deletions
|
@ -37,15 +37,17 @@ public:
|
|||
qmlObject->setObjectName(uuid.toString());
|
||||
// Make sure we can find it again in the future
|
||||
updateQmlItemFromAction();
|
||||
auto connection = QObject::connect(action, &QAction::changed, [=] {
|
||||
_changedConnection = QObject::connect(action, &QAction::changed, [=] {
|
||||
updateQmlItemFromAction();
|
||||
});
|
||||
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=] {
|
||||
QObject::disconnect(connection);
|
||||
_shutdownConnection = QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=] {
|
||||
QObject::disconnect(_changedConnection);
|
||||
});
|
||||
}
|
||||
|
||||
~MenuUserData() {
|
||||
QObject::disconnect(_changedConnection);
|
||||
QObject::disconnect(_shutdownConnection);
|
||||
_action->setUserData(USER_DATA_ID, nullptr);
|
||||
_qml->setUserData(USER_DATA_ID, nullptr);
|
||||
}
|
||||
|
@ -104,6 +106,8 @@ public:
|
|||
private:
|
||||
MenuUserData(const MenuUserData&);
|
||||
|
||||
QMetaObject::Connection _shutdownConnection;
|
||||
QMetaObject::Connection _changedConnection;
|
||||
QAction* _action { nullptr };
|
||||
QObject* _qml { nullptr };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue