summary refs log tree commit diff
path: root/src/MainWindow.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-31 09:10:47 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-31 09:10:47 +0300
commite29fceaee47e0a2edba83605c7fa2789cfb8de1e (patch)
treed25d031444c9cac5859dadba805c93d6953fa68e /src/MainWindow.cpp
parentAdd temp fix to work with servers that don't support e2ee endpoints (diff)
downloadnheko-e29fceaee47e0a2edba83605c7fa2789cfb8de1e.tar.xz
Fix a use-after-free error during logout
Diffstat (limited to '')
-rw-r--r--src/MainWindow.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp

index a93f0c9f..95c56554 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp
@@ -441,15 +441,22 @@ MainWindow::showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> fl } void -MainWindow::openLogoutDialog(std::function<void()> callback) +MainWindow::openLogoutDialog() { auto dialog = new dialogs::Logout(this); - connect(dialog, &dialogs::Logout::closing, this, [this, callback](bool logging_out) { + connect(dialog, &dialogs::Logout::closing, this, [this](bool logging_out) { if (modal_) modal_->hide(); - if (logging_out) - callback(); + // By initiating the logout process a new overlay widget + // will replace & destroy the previous widget (logout dialog). + // + // This will force the destruction of the logout widget to + // happen after the click event has been fully processed. + QTimer::singleShot(0, this, [logging_out, this]() { + if (logging_out) + chat_page_->initiateLogout(); + }); }); showTransparentOverlayModal(dialog, Qt::AlignCenter);