Skip to content

Commit 4f4a1f8

Browse files
committed
Remove idle listener when project is disposed (#164)
1 parent dfa4f0b commit 4f4a1f8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/com/intellij/lang/jsgraphql/ide/project/schemastatus/GraphQLSchemasPanel.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public boolean isToBuildChildrenInBackground(Object element) {
118118
application.executeOnPooledThread(() -> {
119119
// run the schema discovery on a pooled to prevent blocking of the UI thread by asking the nodes for heir child nodes
120120
// the schema caches will be ready when the UI thread then needs to show the tree nodes
121+
if (myProject.isDisposed()) {
122+
return;
123+
}
121124
try {
122125
application.runReadAction(() -> {
123126
// use read action to enable use of indexes
@@ -145,6 +148,8 @@ public boolean isToBuildChildrenInBackground(Object element) {
145148
// update the tree after being idle for a short while
146149
IdeEventQueue.getInstance().addIdleListener(treeUpdater, 750);
147150

151+
Disposer.register(myProject, () -> IdeEventQueue.getInstance().removeIdleListener(treeUpdater));
152+
148153
// update tree on schema or config changes
149154
final MessageBusConnection connection = myProject.getMessageBus().connect();
150155
connection.subscribe(GraphQLSchemaChangeListener.TOPIC, (schemaVersion) -> {

0 commit comments

Comments
 (0)