mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Cleanup cache when a component is deleted from the project
This commit is contained in:
@@ -23,6 +23,7 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -163,6 +164,12 @@ public class DrawingCache {
|
||||
imageCache.clear();
|
||||
}
|
||||
|
||||
public void invalidate(Collection<IDIYComponent<?>> components) {
|
||||
for (IDIYComponent<?> component : components) {
|
||||
imageCache.remove(component);
|
||||
}
|
||||
}
|
||||
|
||||
private CacheValue renderAndCache(IDIYComponent<?> component, G2DWrapper g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project, double zoom) {
|
||||
// if we need to apply caching
|
||||
|
||||
@@ -1772,6 +1772,8 @@ public class Presenter implements IPlugInPort {
|
||||
drawingManager.clearContinuityArea();
|
||||
|
||||
currentProject.getComponents().removeAll(selectedComponents);
|
||||
DrawingCache.Instance.invalidate(selectedComponents);
|
||||
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Delete");
|
||||
drawingManager.clearContinuityArea();
|
||||
projectFileManager.notifyFileChange();
|
||||
|
||||
@@ -3864,7 +3864,11 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Limit memory usage to avoid out of memory errors when 'Cache Boost' feature is enabled</description>
|
||||
<description>Limit memory usage to avoid out of memory errors when 'Cache Boost' feature is enabled on complex project</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Cleanup cache when a component is deleted from the project</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
|
||||
Reference in New Issue
Block a user