mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-16 00:28:26 +00:00
Fixed: Proper freeing memory after SWF close
This commit is contained in:
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
||||
### Fixed
|
||||
- [#2456] FLA export - NullPointer exception while exporting to CS4 or lower via commandline
|
||||
- Touch point, snap align and snap to objects incorrect position when editing nested layers
|
||||
- Proper freeing memory after SWF close
|
||||
|
||||
### Fixed
|
||||
- Resize export dialogs labels to match localized strings
|
||||
|
||||
@@ -6239,4 +6239,12 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public SWF getSwf() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether SWF was freed
|
||||
* @return True if destroyed
|
||||
*/
|
||||
public boolean isDestroyed() {
|
||||
return destroyed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.awt.event.ComponentEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
||||
@@ -1587,6 +1587,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
if (taskThread != null) {
|
||||
taskThread.interrupt();
|
||||
taskThread = null;
|
||||
}
|
||||
|
||||
if (Configuration._debugMode.get() && swf != null) {
|
||||
@@ -1594,10 +1595,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
DecompilerPool d = fSwf.getDecompilerPool();
|
||||
statusPanel.setStatus(fSwf.getFileTitle() + " " + d.getStat());
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
@@ -1620,13 +1620,18 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
isWelcomeScreen = true;
|
||||
quickTagListFindPanel.setVisible(false);
|
||||
quickTreeFindPanel.setVisible(false);
|
||||
doFilter();
|
||||
doFilter();
|
||||
}
|
||||
|
||||
mainFrame.setTitle(ApplicationInfo.applicationVerName);
|
||||
mainMenu.updateComponents(null);
|
||||
|
||||
showView(getCurrentView());
|
||||
|
||||
if (taskThread != null) {
|
||||
taskThread.interrupt();
|
||||
taskThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean closeConfirmation(OpenableList swfList) {
|
||||
@@ -1774,8 +1779,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
int minEasyIndex = Integer.MAX_VALUE;
|
||||
for (SWF swf : swfsToClose) {
|
||||
Main.searchResultsStorage.destroySwf(swf);
|
||||
pinsPanel.removeOpenable(swf);
|
||||
Main.searchResultsStorage.destroySwf(swf);
|
||||
SwfSpecificCustomConfiguration cc = Configuration.getSwfSpecificCustomConfiguration(swf.getShortPathTitle());
|
||||
if (cc != null) {
|
||||
cc.setCustomData(CustomConfigurationKeys.KEY_LOADED_IMPORT_ASSETS, "");
|
||||
@@ -1813,14 +1818,18 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
oldItem = null;
|
||||
clear();
|
||||
|
||||
easyPanel.setSwfIndex(minEasyIndex);
|
||||
Set<SWF> newSwfs = getAllSwfs();
|
||||
|
||||
SWF newEasySwf = easyPanel.getSwf();
|
||||
SWF newEasySwf = null;
|
||||
if (minEasyIndex < newSwfs.size()) {
|
||||
easyPanel.setSwfIndex(minEasyIndex);
|
||||
newEasySwf = easyPanel.getSwf();
|
||||
}
|
||||
|
||||
easyPanel.setSwfs(new ArrayList<>(newSwfs));
|
||||
easyPanel.setSwf(newEasySwf);
|
||||
|
||||
if (currentView == VIEW_EASY) {
|
||||
Set<SWF> swfs = getAllSwfs();
|
||||
easyPanel.setSwfs(new ArrayList<>(swfs));
|
||||
easyPanel.setSwf(newEasySwf);
|
||||
updateUi(newEasySwf);
|
||||
} else {
|
||||
updateUi();
|
||||
|
||||
@@ -365,7 +365,14 @@ public class PinsPanel extends JPanel {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (current != null && current.getOpenable() == openable) {
|
||||
current = null;
|
||||
lastSelectedButton = null;
|
||||
}
|
||||
|
||||
save();
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public void replaceItem(TreeItem oldItem, TreeItem newItem) {
|
||||
|
||||
@@ -275,6 +275,7 @@ public class TagListTreeModel extends AbstractTagTreeModel {
|
||||
|
||||
for (SWF swf : toRemove) {
|
||||
swfHeaders.remove(swf);
|
||||
removeFromCache(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@ import com.jpexs.decompiler.flash.treeitems.Openable;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
@@ -48,6 +50,17 @@ public abstract class AbstractTagTreeModel implements TreeModel {
|
||||
|
||||
protected Map<TreeItem, TreeItem> itemToParentCache = new WeakHashMap<>();
|
||||
|
||||
protected void removeFromCache(TreeItem itemToRemove) {
|
||||
itemToParentCache.remove(itemToRemove);
|
||||
Set<TreeItem> tSet = new HashSet<>(itemToParentCache.keySet());
|
||||
for (TreeItem item : tSet) {
|
||||
TreeItem parent = itemToParentCache.get(item);
|
||||
if (parent == itemToRemove) {
|
||||
removeFromCache(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void calculateCollisions() {
|
||||
Map<TreeItem, Integer> indices = new WeakHashMap<>();
|
||||
calculateCollisions(getRoot(), indices);
|
||||
|
||||
@@ -57,6 +57,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -146,6 +147,7 @@ public class TagTreeModel extends AbstractTagTreeModel {
|
||||
return AppStrings.translate(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSwfs(CollectionChangedEvent e) {
|
||||
if (e.getAction() != CollectionChangedAction.ADD
|
||||
&& e.getAction() != CollectionChangedAction.MOVE) {
|
||||
@@ -159,6 +161,7 @@ public class TagTreeModel extends AbstractTagTreeModel {
|
||||
|
||||
for (SWF swf : toRemove) {
|
||||
swfInfos.remove(swf);
|
||||
removeFromCache(swf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user