4f76fff978
Callers of Notification::Dismiss() assume that the notification instance is not deleted after the call, but this was not the case for LibnotifyNotification: - Destroy() would get `this` deleted. - notify_notification_close() in portal environment triggers LibnotifyNotification::OnNotificationClosed(), and finally calls Destroy() This patch removes all Destroy() in Dismiss(), and adds a boolean to tell whether notify_notification_close() is running, to avoid crash under portal environment. Fixes #40461.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright (c) 2015 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
|
#define ELECTRON_SHELL_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
|
|
|
#include "base/memory/raw_ptr_exclusion.h"
|
|
#include "library_loaders/libnotify_loader.h"
|
|
#include "shell/browser/notifications/notification.h"
|
|
#include "ui/base/glib/scoped_gsignal.h"
|
|
|
|
namespace electron {
|
|
|
|
class LibnotifyNotification : public Notification {
|
|
public:
|
|
LibnotifyNotification(NotificationDelegate* delegate,
|
|
NotificationPresenter* presenter);
|
|
~LibnotifyNotification() override;
|
|
|
|
static bool Initialize();
|
|
|
|
// Notification:
|
|
void Show(const NotificationOptions& options) override;
|
|
void Dismiss() override;
|
|
|
|
private:
|
|
void OnNotificationClosed(NotifyNotification* notification);
|
|
static void OnNotificationView(NotifyNotification* notification,
|
|
char* action,
|
|
gpointer user_data);
|
|
|
|
RAW_PTR_EXCLUSION NotifyNotification* notification_ = nullptr;
|
|
|
|
ScopedGSignal signal_;
|
|
bool on_dismissing_ = false;
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|