summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-01 22:56:31 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-01 23:02:18 +0200
commit51ae913bfe3ee42c7da949b32f313a79e9c9f143 (patch)
treeb449eb78e002f0b0b7194c5c1109dbac0daa8508
parentf4c4b42db90aa16cdedb6d8b9bc9f3ade96a5284 (diff)
downloadserenity-51ae913bfe3ee42c7da949b32f313a79e9c9f143.zip
LibIMAP: Stop leaking a Core::Promise<bool> in IMAP::Client::connect()
-rw-r--r--Userland/Applications/Mail/MailWidget.cpp4
-rw-r--r--Userland/Libraries/LibIMAP/Client.cpp4
-rw-r--r--Userland/Libraries/LibIMAP/Client.h2
-rw-r--r--Userland/Utilities/test-imap.cpp2
4 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp
index d2804e5143..709f7406b5 100644
--- a/Userland/Applications/Mail/MailWidget.cpp
+++ b/Userland/Applications/Mail/MailWidget.cpp
@@ -125,11 +125,11 @@ bool MailWidget::connect_and_login()
m_imap_client = make<IMAP::Client>(server, port, tls);
auto connection_promise = m_imap_client->connect();
- if (!connection_promise.has_value()) {
+ if (!connection_promise) {
GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}.", server, port, tls ? "TLS" : "Plaintext"));
return false;
}
- connection_promise.value()->await();
+ connection_promise->await();
auto response = m_imap_client->login(username, password)->await().release_value();
diff --git a/Userland/Libraries/LibIMAP/Client.cpp b/Userland/Libraries/LibIMAP/Client.cpp
index 4a5b3c244a..9b63733e14 100644
--- a/Userland/Libraries/LibIMAP/Client.cpp
+++ b/Userland/Libraries/LibIMAP/Client.cpp
@@ -21,7 +21,7 @@ Client::Client(StringView host, unsigned int port, bool start_with_tls)
}
}
-Optional<RefPtr<Promise<Empty>>> Client::connect()
+RefPtr<Promise<Empty>> Client::connect()
{
bool success;
if (m_tls) {
@@ -31,7 +31,7 @@ Optional<RefPtr<Promise<Empty>>> Client::connect()
}
if (!success)
return {};
- m_connect_pending = new Promise<bool> {};
+ m_connect_pending = Promise<bool>::construct();
return m_connect_pending;
}
diff --git a/Userland/Libraries/LibIMAP/Client.h b/Userland/Libraries/LibIMAP/Client.h
index e39f88d158..3fb9095dbd 100644
--- a/Userland/Libraries/LibIMAP/Client.h
+++ b/Userland/Libraries/LibIMAP/Client.h
@@ -21,7 +21,7 @@ class Client {
public:
Client(StringView host, unsigned port, bool start_with_tls);
- Optional<RefPtr<Promise<Empty>>> connect();
+ RefPtr<Promise<Empty>> connect();
RefPtr<Promise<Optional<Response>>> send_command(Command&&);
RefPtr<Promise<Optional<Response>>> send_simple_command(CommandType);
void send_raw(StringView data);
diff --git a/Userland/Utilities/test-imap.cpp b/Userland/Utilities/test-imap.cpp
index 4619ee7230..bcafc04532 100644
--- a/Userland/Utilities/test-imap.cpp
+++ b/Userland/Utilities/test-imap.cpp
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
Core::EventLoop loop;
auto client = IMAP::Client(host, port, tls);
- client.connect().value()->await();
+ client.connect()->await();
auto response = client.login(username, password)->await().release_value();
outln("[LOGIN] Login response: {}", response.response_text());