Commit 0cbe2a0000ec9e9c2e0a23acbf94a6a0bfd9b6f2

Authored by Wiebe Cazemier
1 parent e1c7b86f

Fix main app scope in tests

It didn't clean up the old ones, causing unpredictable problems.
FlashMQTests/mainappthread.cpp
... ... @@ -19,15 +19,19 @@ License along with FlashMQ. If not, see <https://www.gnu.org/licenses/>.
19 19  
20 20 MainAppThread::MainAppThread(QObject *parent) : QThread(parent)
21 21 {
  22 + MainApp::initMainApp(1, nullptr);
  23 + appInstance = MainApp::getMainApp();
  24 + appInstance->settings->allowAnonymous = true;
  25 +}
  26 +
  27 +MainAppThread::~MainAppThread()
  28 +{
22 29 if (appInstance)
23 30 {
24 31 delete appInstance;
  32 + MainApp::instance = nullptr;
25 33 }
26 34 appInstance = nullptr;
27   - MainApp::instance = nullptr;
28   - MainApp::initMainApp(1, nullptr);
29   - appInstance = MainApp::getMainApp();
30   - appInstance->settings->allowAnonymous = true;
31 35 }
32 36  
33 37 void MainAppThread::run()
... ...
FlashMQTests/mainappthread.h
... ... @@ -28,6 +28,7 @@ class MainAppThread : public QThread
28 28 MainApp *appInstance = nullptr;
29 29 public:
30 30 explicit MainAppThread(QObject *parent = nullptr);
  31 + ~MainAppThread();
31 32  
32 33 public slots:
33 34 void run() override;
... ...
FlashMQTests/tst_maintests.cpp
... ... @@ -102,6 +102,7 @@ MainTests::~MainTests()
102 102  
103 103 void MainTests::init()
104 104 {
  105 + mainApp.reset();
105 106 mainApp.reset(new MainAppThread());
106 107 mainApp->start();
107 108 mainApp->waitForStarted();
... ...