diff --git a/Userland/Libraries/LibGUI/Notification.cpp b/Userland/Libraries/LibGUI/Notification.cpp index d863309300..f38141044c 100644 --- a/Userland/Libraries/LibGUI/Notification.cpp +++ b/Userland/Libraries/LibGUI/Notification.cpp @@ -54,7 +54,6 @@ private: }; Notification::Notification() - : m_connection(NotificationServerConnection::construct()) { } @@ -64,73 +63,40 @@ Notification::~Notification() void Notification::show() { - VERIFY(!m_showing); - VERIFY(!m_disposed); - if (!m_connection->is_connected()) { - // This would imply that the NotificationServer crashed before we could send it any data. - VERIFY_NOT_REACHED(); - } + VERIFY(!m_connection); auto icon = m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap(); + m_connection = NotificationServerConnection::construct(); m_connection->send_sync(m_text, m_title, icon); - m_showing = true; } void Notification::close() { - VERIFY(m_showing); - if (m_connection->is_connected()) { - m_connection->send_sync(); + VERIFY(m_connection); + if (!m_connection->is_connected()) { + return; } - - m_showing = false; - m_disposed = true; + m_connection->send_sync(); } bool Notification::update() { - VERIFY(m_showing); - VERIFY(!m_disposed); + VERIFY(m_connection); if (!m_connection->is_connected()) { - m_showing = false; - m_disposed = true; return false; } - bool is_checked = false; - if (m_text_dirty || m_title_dirty) { - auto response = m_connection->send_sync(m_text, m_title); + m_connection->send_sync(m_text, m_title); m_text_dirty = false; m_title_dirty = false; - - is_checked = true; - if (!response->still_showing()) { - m_showing = false; - m_disposed = true; - return false; - } } if (m_icon_dirty) { - auto response = m_connection->send_sync(m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap()); + m_connection->send_sync(m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap()); m_icon_dirty = false; - - is_checked = true; - if (!response->still_showing()) { - m_showing = false; - m_disposed = true; - return false; - } } - if (!is_checked) { - auto response = m_connection->send_sync(); - m_showing = response->still_showing(); - if (!m_showing) { - m_disposed = true; - } - } - return m_showing; + return true; } } diff --git a/Userland/Libraries/LibGUI/Notification.h b/Userland/Libraries/LibGUI/Notification.h index 1dda17d757..e949d7fc24 100644 --- a/Userland/Libraries/LibGUI/Notification.h +++ b/Userland/Libraries/LibGUI/Notification.h @@ -74,9 +74,7 @@ private: RefPtr m_icon; bool m_icon_dirty; - NonnullRefPtr m_connection; - bool m_showing { false }; - bool m_disposed { false }; + RefPtr m_connection; }; }