#848 Random Reversion to Unedited Code when Toggling the 3 switches (at Top Left) on the Right Hand Pane! fixed

This commit is contained in:
honfika@gmail.com
2015-04-09 08:39:55 +02:00
parent 22751367cd
commit 7ee0351167
7 changed files with 43 additions and 36 deletions

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action;
import com.jpexs.decompiler.flash.DisassemblyListener;
@@ -342,7 +343,7 @@ public class ActionListReader {
return next
? (min < actions.size() ? actions.get(min).getAddress() : -1)
? (min < actions.size() ? actions.get(min).getAddress() : -1)
: (max >= 0 ? actions.get(max).getAddress() : -1);
}
private static Map<Long, Action> actionListToMap(List<Action> actions) {

View File

@@ -56,6 +56,10 @@ public class FolderItem implements TreeItem {
@Override
public boolean isModified() {
if (subItems == null) {
return false;
}
for (TreeItem ti : subItems) {
if (ti.isModified()) {
return true;

View File

@@ -617,6 +617,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
this.swfs.addCollectionChangedListener((e) -> {
TagTreeModel ttm = tagTree.getModel();
if (ttm != null) {
if (getCurrentSwf() == null) {
tagTree.setSelectionPath(ttm.getTreePath(ttm.getRoot()));
}
ttm.updateSwfs(e);
TreeItem root = ttm.getRoot();
int childCount = ttm.getChildCount(root);

View File

@@ -181,6 +181,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
}
textWithHex = null;
textNoHex = null;
textHexOnly = null;
setHex(exportMode, true);
}
@@ -236,6 +237,9 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
}
((Tag) abc.parentTag).setModified(true);
abc.script_info.get(scriptIndex).setModified(true);
textWithHex = null;
textNoHex = null;
textHexOnly = null;
} catch (IOException ex) {
} catch (InterruptedException ex) {
} catch (AVM2ParseException ex) {

View File

@@ -681,9 +681,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
if (val) {
if (rawEdit) {
setText(srcHexOnly, "text/plain");
setHex(ScriptExportMode.HEX);
} else {
setText(srcNoHex, "text/flasm");
setHex(ScriptExportMode.PCODE);
}
editor.setEditable(true);
saveButton.setVisible(true);

View File

@@ -172,11 +172,16 @@ public class TagTree extends JTree {
int row,
boolean hasFocus) {
TreeItem val = (TreeItem) value;
if (val.getSwf() == null) {
// SWF was closed
value = null;
}
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
TreeItem val = (TreeItem) value;
TreeNodeType type = getTreeNodeType(val);
if (type == TreeNodeType.FOLDER && expanded) {
@@ -560,6 +565,7 @@ public class TagTree extends JTree {
if (!mainPanel.folderPreviewPanel.selectedItems.isEmpty()) {
return mainPanel.folderPreviewPanel.selectedItems.entrySet().iterator().next().getValue();
}
TreeItem item = (TreeItem) getLastSelectedPathComponent();
return item;
}

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.TreeNodeType;
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
import com.jpexs.decompiler.flash.gui.helpers.CollectionChangedAction;
import com.jpexs.decompiler.flash.gui.helpers.CollectionChangedEvent;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
@@ -102,25 +103,7 @@ public class TagTreeModel implements TreeModel {
}
public void updateSwfs(CollectionChangedEvent e) {
boolean cleanMap = false;
switch (e.getAction()) {
case ADD: {
TreePath rootPath = new TreePath(new Object[]{root});
fireTreeNodesInserted(new TreeModelEvent(this, rootPath, new int[]{e.getNewIndex()}, new Object[]{e.getNewItem()}));
break;
}
case REMOVE: {
TreePath rootPath = new TreePath(new Object[]{root});
fireTreeNodesRemoved(new TreeModelEvent(this, rootPath, new int[]{e.getOldIndex()}, new Object[]{e.getOldItem()}));
cleanMap = true;
break;
}
default:
cleanMap = true;
fireTreeStructureChanged(new TreeModelEvent(this, new TreePath(root)));
}
if (cleanMap) {
if (e.getAction() != CollectionChangedAction.ADD) {
List<SWF> toRemove = new ArrayList<>();
for (SWF swf : swfInfos.keySet()) {
SWF swf2 = swf.getRootSwf();
@@ -133,6 +116,21 @@ public class TagTreeModel implements TreeModel {
swfInfos.remove(swf);
}
}
switch (e.getAction()) {
case ADD: {
TreePath rootPath = new TreePath(new Object[]{root});
fireTreeNodesInserted(new TreeModelEvent(this, rootPath, new int[]{e.getNewIndex()}, new Object[]{e.getNewItem()}));
break;
}
case REMOVE: {
TreePath rootPath = new TreePath(new Object[]{root});
fireTreeNodesRemoved(new TreeModelEvent(this, rootPath, new int[]{e.getOldIndex()}, new Object[]{e.getOldItem()}));
break;
}
default:
fireTreeStructureChanged(new TreeModelEvent(this, new TreePath(root)));
}
}
public void updateSwf(SWF swf) {
@@ -602,15 +600,8 @@ public class TagTreeModel implements TreeModel {
}
if (result instanceof Tag) {
Tag resultTag = (Tag) result;
TagScript tagScript = null;
Map<Tag, TagScript> currentTagScriptCache = null;
if (swfInfos != null && result.getSwf() != null) {
TagTreeSwfInfo ttsi = swfInfos.get(result.getSwf());
if (ttsi != null) {
currentTagScriptCache = ttsi.tagScriptCache;
tagScript = currentTagScriptCache.get(resultTag);
}
}
Map<Tag, TagScript> currentTagScriptCache = swfInfos.get(result.getSwf()).tagScriptCache;
TagScript tagScript = currentTagScriptCache.get(resultTag);
if (tagScript == null) {
List<TreeItem> subNodes = new ArrayList<>();
if (result instanceof ASMSourceContainer) {
@@ -619,9 +610,7 @@ public class TagTreeModel implements TreeModel {
}
}
tagScript = new TagScript(result.getSwf(), resultTag, subNodes);
if (currentTagScriptCache != null) {
currentTagScriptCache.put(resultTag, tagScript);
}
currentTagScriptCache.put(resultTag, tagScript);
}
result = tagScript;
}