Fix a use-after-free error during logout

This commit is contained in:
Konstantinos Sideris 2018-08-31 09:10:47 +03:00
parent b10e1bafc8
commit e29fceaee4
6 changed files with 34 additions and 28 deletions

View file

@ -169,24 +169,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
});
connect(this, &ChatPage::loggedOut, this, &ChatPage::logout);
connect(user_info_widget_, &UserInfoWidget::logout, this, [this]() {
http::client()->logout(
[this](const mtx::responses::Logout &, mtx::http::RequestErr err) {
if (err) {
// TODO: handle special errors
emit contentLoaded();
nhlog::net()->warn(
"failed to logout: {} - {}",
mtx::errors::to_string(err->matrix_error.errcode),
err->matrix_error.error);
return;
}
emit loggedOut();
});
emit showOverlayProgressBar();
});
connect(top_bar_, &TopRoomBar::showRoomList, splitter, &Splitter::showFullRoomList);
connect(top_bar_, &TopRoomBar::inviteUsers, this, [this](QStringList users) {
@ -1332,3 +1314,22 @@ ChatPage::isSideBarExpanded()
{
return sideBar_->size().width() > ui::sidebar::NormalSize;
}
void
ChatPage::initiateLogout()
{
http::client()->logout([this](const mtx::responses::Logout &, mtx::http::RequestErr err) {
if (err) {
// TODO: handle special errors
emit contentLoaded();
nhlog::net()->warn("failed to logout: {} - {}",
mtx::errors::to_string(err->matrix_error.errcode),
err->matrix_error.error);
return;
}
emit loggedOut();
});
emit showOverlayProgressBar();
}