Slight modifications to prevent an exception in certain situations.

Thu, 21 Jan 2021 19:24:59 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 21 Jan 2021 19:24:59 +0100
changeset 7996
ce1d288659ae
parent 7995
d570d9aab754
child 7997
2ca23396c25c

Slight modifications to prevent an exception in certain situations.

eric6/UI/NotificationWidget.py file | annotate | diff | comparison | revisions
--- a/eric6/UI/NotificationWidget.py	Mon Jan 18 11:43:06 2021 +0100
+++ b/eric6/UI/NotificationWidget.py	Thu Jan 21 19:24:59 2021 +0100
@@ -135,6 +135,7 @@
         self.__timeout = 5000
         self.__dragPosition = QPoint()
         self.__timers = {}
+        self.__notifications = []
         
         self.__settingPosition = setPosition
         
@@ -171,6 +172,7 @@
         notificationFrame = NotificationFrame(
             icon, heading, text, kind=kind, parent=self)
         self.__layout.addWidget(notificationFrame)
+        self.__notifications.append(notificationFrame)
         
         self.show()
         
@@ -178,7 +180,7 @@
         
         if timeout:
             timer = QTimer()
-            self.__timers[repr(notificationFrame)] = timer
+            self.__timers[id(notificationFrame)] = timer
             timer.setSingleShot(True)
             timer.timeout.connect(
                 lambda: self.__removeNotification(notificationFrame)
@@ -225,7 +227,7 @@
         notification.hide()
         
         # delete timer of an auto close notification
-        key = repr(notification)
+        key = id(notification)
         if key in self.__timers:
             self.__timers[key].stop()
             del self.__timers[key]
@@ -233,6 +235,7 @@
         # delete the notification
         index = self.__layout.indexOf(notification)
         self.__layout.takeAt(index)
+        self.__notifications.remove(notification)
         notification.deleteLater()
         
         if self.__layout.count():

eric ide

mercurial