From 006fcb764a718706136486339b161530539642da Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Tue, 28 Jul 2009 14:23:30 +0400 Subject: [PATCH] IDEADEV-39059 NotificationManager keeps NotificationWrappers for closed projects and thus leaks memory --- .../notification/impl/NotificationModel.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/platform-impl/src/com/intellij/notification/impl/NotificationModel.java b/platform-impl/src/com/intellij/notification/impl/NotificationModel.java index ab6b1719bd..23c2a37a05 100644 --- a/platform-impl/src/com/intellij/notification/impl/NotificationModel.java +++ b/platform-impl/src/com/intellij/notification/impl/NotificationModel.java @@ -139,15 +139,20 @@ public class NotificationModel { public void clear(@NotNull NotNullFunction filter) { final LinkedList result = filterNotifications(filter); - if (!result.isEmpty()) { - for (final T notification : result) { - myNotifications.remove(notification); - } + for (final T notification : result) { + myNotifications.remove(notification); + } - final T[] removed = result.toArray((T[])Array.newInstance(result.get(0).getClass(), result.size())); - for (NotificationModelListener listener : myListeners) { - listener.notificationsRemoved(removed); - } + final Collection archive = getArchive(filter); + for (final T notification : archive) { + myArchive.remove(notification); + } + + result.addAll(archive); + + final T[] removed = result.toArray((T[])Array.newInstance(result.get(0).getClass(), result.size())); + for (NotificationModelListener listener : myListeners) { + listener.notificationsRemoved(removed); } } -- 2.11.4.GIT