mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Platform: Memory leak in FileChangedNotificationProvider
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Manager of listeners for notifications about activation and deactivation of the
|
||||
@@ -40,14 +43,15 @@ public abstract class FrameStateManager {
|
||||
*
|
||||
* @param listener the listener instance.
|
||||
*/
|
||||
public abstract void addListener(FrameStateListener listener);
|
||||
public abstract void addListener(@NotNull FrameStateListener listener);
|
||||
public abstract void addListener(@NotNull FrameStateListener listener, @Nullable Disposable disposable);
|
||||
|
||||
/**
|
||||
* Removes a listener which is called when the IDEA window is activated or deactivated.
|
||||
*
|
||||
* @param listener the listener instance.
|
||||
*/
|
||||
public abstract void removeListener(FrameStateListener listener);
|
||||
public abstract void removeListener(@NotNull FrameStateListener listener);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ public class FileChangedNotificationProvider extends EditorNotifications.Provide
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,16 +15,19 @@
|
||||
*/
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationActivationListener;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.BusyObject;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -105,11 +108,21 @@ public class FrameStateManagerImpl extends FrameStateManager implements Applicat
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addListener(FrameStateListener listener) {
|
||||
myListeners.add(listener);
|
||||
public synchronized void addListener(@NotNull FrameStateListener listener) {
|
||||
addListener(listener, null);
|
||||
}
|
||||
|
||||
public synchronized void removeListener(FrameStateListener listener) {
|
||||
public synchronized void addListener(@NotNull final FrameStateListener listener, @Nullable Disposable disposable) {
|
||||
myListeners.add(listener);
|
||||
if (disposable != null) Disposer.register(disposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
removeListener(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void removeListener(@NotNull FrameStateListener listener) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user