From 7351c77a423108eaac1b1f6ab0abb11f6c601ee7 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 11 Mar 2021 13:37:26 -0600 Subject: [PATCH] LibGUI+Notification: Use lifetime connection In order to allow notifications to be updated, we will create a persistent connection for the lifetime of the notification. --- Userland/Libraries/LibGUI/Notification.cpp | 4 ++-- Userland/Libraries/LibGUI/Notification.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/Notification.cpp b/Userland/Libraries/LibGUI/Notification.cpp index 51667d6a97..34e06345c9 100644 --- a/Userland/Libraries/LibGUI/Notification.cpp +++ b/Userland/Libraries/LibGUI/Notification.cpp @@ -49,6 +49,7 @@ private: }; Notification::Notification() + : m_connection(NotificationServerConnection::construct()) { } @@ -58,9 +59,8 @@ Notification::~Notification() void Notification::show() { - auto connection = NotificationServerConnection::construct(); auto icon = m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap(); - connection->send_sync(m_text, m_title, icon); + m_connection->send_sync(m_text, m_title, icon); } } diff --git a/Userland/Libraries/LibGUI/Notification.h b/Userland/Libraries/LibGUI/Notification.h index 1b86bc8199..b26c5aa0fa 100644 --- a/Userland/Libraries/LibGUI/Notification.h +++ b/Userland/Libraries/LibGUI/Notification.h @@ -30,6 +30,7 @@ #include namespace GUI { + class NotificationServerConnection; class Notification : public Core::Object { C_OBJECT(Notification); @@ -54,6 +55,8 @@ private: String m_title; String m_text; RefPtr m_icon; + + NonnullRefPtr m_connection; }; }