Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/430 fix unclean shutdown #580

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -347,7 +347,7 @@ MainWindow::~MainWindow()

void MainWindow::appExit()
{
appExitCalled = true;
m_appExitCalled = true;
close();
}

Expand Down Expand Up @@ -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();
Expand All @@ -680,6 +686,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
bool accept = saveLastDatabases();

if (accept) {
m_appExiting = true;
saveWindowInformation();

event->accept();
Expand Down
4 changes: 3 additions & 1 deletion src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MainWindow : public QMainWindow
public:
MainWindow();
~MainWindow();

enum StackedWidgetIndex
{
DatabaseTabScreen = 0,
Expand Down Expand Up @@ -118,7 +119,8 @@ private slots:

Q_DISABLE_COPY(MainWindow)

bool appExitCalled;
bool m_appExitCalled;
bool m_appExiting;
};

#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \
Expand Down