various small fixes

This commit is contained in:
2015-04-25 20:21:10 +02:00
parent 2900dd90e0
commit e700f91bf7
8 changed files with 59 additions and 28 deletions
@@ -916,7 +916,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
int msPerFrame = frameRate == 0 ? 1000 : 1000 / frameRate;
final int cnt = counter;
final boolean singleFrame = timeline.getFrameCount() <= 1 && timeline.isSingleFrame();
final boolean singleFrame = timeline.getRealFrameCount() <= 1 && timeline.isSingleFrame();
shouldDraw.set(true);
startTimer(cnt, singleFrame, msPerFrame);
}
@@ -139,4 +139,16 @@ public class LoadingPanel extends JPanel {
g2.setTransform(t);
g2.drawImage(lastImage, 0, 0, this);
}
@Override
public void setVisible(boolean visible) {
if (!visible) {
if (drawTimer != null) {
drawTimer.cancel();
drawTimer = null;
}
}
super.setVisible(visible);
}
}
+6 -1
View File
@@ -439,9 +439,11 @@ public class Main {
} catch (OutOfMemoryError ex) {
logger.log(Level.SEVERE, null, ex);
View.showMessageDialog(null, "Cannot load SWF file. Out of memory.");
continue;
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
View.showMessageDialog(null, "Cannot load SWF file.");
continue;
}
final SWFList swfs1 = swfs;
@@ -1106,7 +1108,10 @@ public class Main {
MainPanel mainPanel = mainFrame.getPanel();
TreePath tp = View.getTreePathByPathStrings(mainPanel.tagTree, Arrays.asList(path));
mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent());
if (tp != null) {
// the current view is the Resources view, otherwise tp is null
mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent());
}
}
});
}
@@ -538,6 +538,10 @@ public class View {
public static TreePath getTreePathByPathStrings(JTree tree, List<String> pathAsStringList) {
TreeModel model = tree.getModel();
if (model == null) {
return null;
}
Object node = model.getRoot();
if (pathAsStringList.isEmpty()) {
@@ -184,21 +184,30 @@ public final class FlashPlayerPanel extends Panel implements Closeable, MediaDis
@Override
public void run() {
boolean changed = false;
try {
ShockwaveFlash flash1 = flash;
if (flash1 == null) {
return;
}
boolean isPlaying = flash.IsPlaying();
if (this.isPlaying != isPlaying) {
this.isPlaying = isPlaying;
}
boolean changed = false;
int currentFrame = flash.CurrentFrame();
if (this.currentFrame != currentFrame) {
this.currentFrame = currentFrame;
changed = true;
}
boolean isPlaying = flash1.IsPlaying();
if (this.isPlaying != isPlaying) {
this.isPlaying = isPlaying;
}
if (changed) {
fireMediaDisplayStateChanged();
int currentFrame = flash1.CurrentFrame();
if (this.currentFrame != currentFrame) {
this.currentFrame = currentFrame;
changed = true;
}
if (changed) {
fireMediaDisplayStateChanged();
}
} catch (Exception ex) {
// ignore
}
}
}, 100, 100);