better handling of corrupt swf files

This commit is contained in:
honfika
2014-07-25 22:12:46 +02:00
parent f6969d442a
commit 1bd0504402
37 changed files with 2416 additions and 2349 deletions
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.gui.generictageditors.NumberEditor;
import com.jpexs.decompiler.flash.gui.generictageditors.ReflectionTools;
import com.jpexs.decompiler.flash.gui.generictageditors.StringEditor;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.TagStub;
import com.jpexs.decompiler.flash.types.ARGB;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RGB;
@@ -661,7 +662,9 @@ public class GenericTagTreePanel extends GenericTagPanel {
this.tag = tag;
SWF swf = tag.getSwf();
try {
this.editedTag = SWFInputStream.resolveTag(tag, 0, false, true, swf.gfx);
if (tag instanceof TagStub) {
this.editedTag = SWFInputStream.resolveTag((TagStub)tag, 0, false, true, swf.gfx);
}
} catch (InterruptedException ex) {
}
tree.setEditable(edit);
@@ -54,6 +54,7 @@ import java.awt.geom.AffineTransform;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -213,7 +214,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
Timeline tim = ((Timelined) timelined).getTimeline();
BoundedTag bounded = (BoundedTag) timelined;
RECT rect = bounded.getRect();
RECT rect = bounded.getRect(new HashSet<BoundedTag>());
int width = rect.getWidth();
double scale = 1.0;
/*if (width > swf.displayRect.getWidth()) {
@@ -495,7 +496,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (img == null) {
if (drawable instanceof BoundedTag) {
BoundedTag bounded = (BoundedTag) drawable;
RECT rect = bounded.getRect();
RECT rect = bounded.getRect(new HashSet<BoundedTag>());
if (rect == null) { //??? Why?
rect = new RECT(0, 0, 1, 1);
}
@@ -169,10 +169,12 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -245,7 +247,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private JTextField filterField = new MyTextField("");
private JPanel searchPanel;
private final PreviewPanel previewPanel;
private HeaderInfoPanel headerPanel;
private final HeaderInfoPanel headerPanel;
private DumpViewPanel dumpViewPanel;
private final JPanel treePanel;
private TreePanelMode treePanelMode;
@@ -2315,7 +2317,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
DefineSpriteTag parentSprite = (DefineSpriteTag) fn.getParent();
controlTags = parentSprite.subTags;
containerId = parentSprite.spriteId;
rect = parentSprite.getRect();
rect = parentSprite.getRect(new HashSet<BoundedTag>());
totalFrameCount = parentSprite.frameCount;
timelined = parentSprite;
}
@@ -2513,7 +2515,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (tim != null) {
return tim;
}
tim = new Timeline(tag.getSwf(), new ArrayList<Tag>(), ((CharacterTag) tag).getCharacterId(), getRect());
tim = new Timeline(tag.getSwf(), new ArrayList<Tag>(), ((CharacterTag) tag).getCharacterId(), getRect(new HashSet<BoundedTag>()));
if (tag instanceof MorphShapeTag) {
tim.frameRate = MORPH_SHAPE_ANIMATION_FRAME_RATE;
int framesCnt = tim.frameRate * MORPH_SHAPE_ANIMATION_LENGTH;
@@ -2544,8 +2546,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
ds.matrix = new MATRIX();
f.layers.put(1, ds);
tim.frames.add(f);
}
tim.displayRect = getRect();
}
tim.displayRect = getRect(new HashSet<BoundedTag>());
return tim;
}
@@ -2555,8 +2557,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
@Override
public RECT getRect() {
return ((BoundedTag) tag).getRect();
public RECT getRect(Set<BoundedTag> added) {
BoundedTag bt = (BoundedTag) tag;
if (!added.contains(bt)) {
return bt.getRect(added);
}
return new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE);
}
};
}
@@ -42,6 +42,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.AffineTransform;
import java.util.HashSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -185,7 +186,7 @@ public class PreviewImage extends JPanel {
height = (imgSrc.getHeight());
} else if (treeItem instanceof BoundedTag) {
BoundedTag boundedTag = (BoundedTag) treeItem;
RECT rect = boundedTag.getRect();
RECT rect = boundedTag.getRect(new HashSet<BoundedTag>());
width = (int) (rect.getWidth() / SWF.unitDivisor) + 1;
height = (int) (rect.getHeight() / SWF.unitDivisor) + 1;
m.translate(-rect.Xmin, -rect.Ymin);
@@ -575,7 +575,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
}
mat = Helper.deepCopy(mat);
if (parent instanceof BoundedTag) {
RECT r = ((BoundedTag) parent).getRect();
RECT r = ((BoundedTag) parent).getRect(new HashSet<BoundedTag>());
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2;
} else {
@@ -617,7 +617,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
mat.translateX = 0;
mat.translateY = 0;
if (tagObj instanceof BoundedTag) {
RECT r = ((BoundedTag) tagObj).getRect();
RECT r = ((BoundedTag) tagObj).getRect(new HashSet<BoundedTag>());
mat.translateX = -r.Xmin;
mat.translateY = -r.Ymin;
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;