Skip to content

Commit

Permalink
making sure haxelibCache instances are cleaned up.
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Jun 4, 2023
1 parent 006491b commit 3ecbca4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public static HaxelibCacheManager getInstance(@NotNull Module module) {
return instances.get(module);
}

public static void removeInstance(@NotNull Module module) {
instances.remove(module);
}


private final Map<String, List<String>> installedLibraries = new HashMap<>();
private final Map<String, List<String>> availableLibraries = new HashMap<>();
Expand All @@ -34,6 +38,8 @@ private HaxelibCacheManager(Module module) {
this.module = module;
}



public void clear() {
installedLibraries.clear();
availableLibraries.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public void modulesAdded(@NotNull Project project, @NotNull List<? extends Modul
}
}

@Override
public void moduleRemoved(@NotNull Project project, @NotNull Module module) {
HaxelibCacheManager.removeInstance(module);
}

@Override
public void dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.intellij.plugins.haxe.haxelib;

import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.LogLevel;
Expand Down Expand Up @@ -138,12 +139,14 @@ public boolean closeProject(Project project) {

ProjectTracker tracker = myProjects.get(project);
removed = myProjects.remove(project);

if (removed) {
myQueue.remove(tracker);
if (tracker.equals(myQueue.getUpdatingProject())) {
delayed = true;
}
}
tracker.dispose();
return delayed;
}

Expand Down Expand Up @@ -1199,7 +1202,7 @@ public void setPropertiesList(HaxeLibraryList propertiesList) {
/**
* Tracks the state of a project for updating class paths.
*/
public final class ProjectTracker {
public final class ProjectTracker implements Disposable {
final Project myProject;
boolean myIsDirty;
boolean myIsUpdating;
Expand Down Expand Up @@ -1397,6 +1400,12 @@ private String getBuildConfigFile(HaxeModuleSettings settings) {
default -> "N/A";
};
}

@Override
public void dispose() {
Collection<Module> modules = ModuleUtil.getModulesOfType(getProject(), HaxeModuleType.getInstance());
modules.forEach(HaxelibCacheManager::removeInstance);
}
} // end class ProjectTracker


Expand Down

0 comments on commit 3ecbca4

Please sign in to comment.