From 0304685072de3a7bd29eae4b049a36e4b2ce5bae Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Mon, 31 Dec 2018 16:49:35 -0500
Subject: [PATCH] mainwindow: disconnect from active changed signal before exit

Change-Id: Ib671e20016a2372ac2abbac7060b44ac0d1b90c4
---
 mainwindow.cpp | 5 ++---
 mainwindow.h   | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mainwindow.cpp b/mainwindow.cpp
index ca6d720..3bb7fed 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -150,10 +150,8 @@ MainWindow::MainWindow(QWidget* parent) :
 
     lastScr_ = startScreen;
 
-    connect(windowHandle(), &QWindow::activeChanged,
+    activeChangedConnection_ = connect(windowHandle(), &QWindow::activeChanged,
         [this]() {
-            if (!qApp)
-                return;
             auto screenNumber = qApp->desktop()->screenNumber();
             QScreen* screen = qApp->screens().at(screenNumber);
             windowHandle()->setScreen(nullptr);
@@ -293,6 +291,7 @@ MainWindow::closeEvent(QCloseEvent* event)
         settings.setValue(SettingsKey::windowState, saveState());
     }
     this->disconnect(screenChangedConnection_);
+    this->disconnect(activeChangedConnection_);
     LRCInstance::reset();
     QMainWindow::closeEvent(event);
 }
diff --git a/mainwindow.h b/mainwindow.h
index 02e6138..e2bce37 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -85,4 +85,5 @@ private:
     Ui::MainWindow* ui;
     QNetworkConfigurationManager netManager_;
     QMetaObject::Connection screenChangedConnection_;
+    QMetaObject::Connection activeChangedConnection_;
 };
-- 
GitLab