Merge pull request #580 from keepassxreboot/feature/430-fix-unclean-shutdown

Feature/430 fix unclean shutdown
This commit is contained in:
Janek Bevendorff 2017-05-17 23:18:46 +02:00 committed by GitHub
commit aa64b2ee69
2 changed files with 14 additions and 5 deletions

View File

@ -103,9 +103,9 @@ const QString MainWindow::BaseWindowTitle = "KeePassXC";
MainWindow::MainWindow()
: m_ui(new Ui::MainWindow())
, m_trayIcon(nullptr)
, m_appExitCalled(false)
, m_appExiting(false)
{
appExitCalled = false;
m_ui->setupUi(this);
// Setup the search widget in the toolbar
@ -347,7 +347,7 @@ MainWindow::~MainWindow()
void MainWindow::appExit()
{
appExitCalled = true;
m_appExitCalled = true;
close();
}
@ -663,9 +663,15 @@ void MainWindow::databaseTabChanged(int tabIndex)
void MainWindow::closeEvent(QCloseEvent* event)
{
// ignore double close events (happens on macOS when closing from the dock)
if (m_appExiting) {
event->accept();
return;
}
bool minimizeOnClose = isTrayIconEnabled() &&
config()->get("GUI/MinimizeOnClose").toBool();
if (minimizeOnClose && !appExitCalled)
if (minimizeOnClose && !m_appExitCalled)
{
event->ignore();
hideWindow();
@ -680,6 +686,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
bool accept = saveLastDatabases();
if (accept) {
m_appExiting = true;
saveWindowInformation();
event->accept();

View File

@ -40,6 +40,7 @@ class MainWindow : public QMainWindow
public:
MainWindow();
~MainWindow();
enum StackedWidgetIndex
{
DatabaseTabScreen = 0,
@ -118,7 +119,8 @@ private:
Q_DISABLE_COPY(MainWindow)
bool appExitCalled;
bool m_appExitCalled;
bool m_appExiting;
};
#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \