From 83f68573324a453a6d26e025fd6439f175a79d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= Date: Wed, 22 Dec 2021 17:36:29 -0500 Subject: [PATCH] mainapplication: fix destruction ordering Every models (like UtilsAdapter for example) owns a pointer of LRCInstance. So, when the MainApplication is destroyed, the QmlEngine and all structures owning a pointer of LRCInstance MUST be destroyed before LRCInstance to avoid any segfault GitLab: #631 Change-Id: Id30aaca325fe7172188bba468acd73525e62a34a --- src/mainapplication.cpp | 6 +++++- src/mainapplication.h | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index 0c3209fc..278f1928 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -155,7 +155,11 @@ MainApplication::MainApplication(int& argc, char** argv) QObject::connect(this, &QApplication::aboutToQuit, [this] { cleanup(); }); } -MainApplication::~MainApplication() {} +MainApplication::~MainApplication() +{ + engine_.reset(); + lrcInstance_.reset(); +} bool MainApplication::init() diff --git a/src/mainapplication.h b/src/mainapplication.h index 51306be8..4047e3ab 100644 --- a/src/mainapplication.h +++ b/src/mainapplication.h @@ -80,7 +80,6 @@ private: private: QScopedPointer debugFile_; QScopedPointer engine_; - QScopedPointer lrcInstance_; QScopedPointer connectivityMonitor_;