Skip to content

Commit 08fb98c

Browse files
vkoskivADKaster
authored andcommitted
Mail: Fix crash when closing window before IMAP::Client connects
`MailWidget::m_imap_client` is only assigned after a connection is established, so the user might close the main window before that happens, especially if the connection hangs for whatever reason. Now we check the `OwnPtr` before working with it.
1 parent 055d2b6 commit 08fb98c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Userland/Applications/Mail/MailWidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ bool MailWidget::connect_and_login()
163163

164164
void MailWidget::on_window_close()
165165
{
166+
if (!m_imap_client) {
167+
// User closed main window before a connection was established
168+
return;
169+
}
166170
auto response = move(MUST(m_imap_client->send_simple_command(IMAP::CommandType::Logout)->await()).release_value().get<IMAP::SolidResponse>());
167171
VERIFY(response.status() == IMAP::ResponseStatus::OK);
168172

0 commit comments

Comments
 (0)