[gnome-shell/wip/cosimoc/notification-refactor] calendar: do not call destroy() recursively



commit 4c3e3ac56e11ad81ccf8275386fd5a4e3ef20dbf
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Wed Oct 10 19:08:38 2018 -0700

    calendar: do not call destroy() recursively
    
    We have a callback that will call close() when the notification is
    destroyed, and a callback that will call destroy() on the notification
    when the message is closed.
    
    Currently, if the notification is destroyed we'll execute our callback
    that will call again destroy() on the notification. That's bad
    practice in general, and it also has the side effect of resetting the
    destroy reason.
    
    Add a flag to the class to detect this case, and avoid re-destroying
    the notification.

 js/ui/calendar.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 815c9f9c9..b40d37b51 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -773,9 +773,11 @@ var NotificationMessage = new Lang.Class({
 
         this.connect('close', () => {
             this._closed = true;
-            this.notification.destroy(MessageTray.NotificationDestroyedReason.DISMISSED);
+            if (!this._notificationDestroyed)
+                this.notification.destroy(MessageTray.NotificationDestroyedReason.DISMISSED);
         });
         this._destroyId = notification.connect('destroy', () => {
+            this._notificationDestroyed = true;
             if (!this._closed)
                 this.close();
         });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]