loading dialog fix

This commit is contained in:
honfika@gmail.com
2015-01-20 16:19:07 +01:00
parent 4dcde9045b
commit 526edda6fa
4 changed files with 36 additions and 29 deletions

View File

@@ -881,7 +881,7 @@ public class CommandLineArgumentParser {
SWF exfile = new SWF(new FileInputStream(inFile), Configuration.parallelSpeedUp.get());
String outDir = outDirBase.getAbsolutePath();
if (!singleFile) {
Path.combine(outDir, exfile.getShortFileName());
outDir = Path.combine(outDir, inFile.getName());
}
List<Tag> extags = new ArrayList<>();

View File

@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.ApplicationInfo;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.ImageObserver;
@@ -67,10 +66,9 @@ public class LoadingDialog extends AppDialog implements ImageObserver {
/**
* Constructor
*
* @param owner
*/
public LoadingDialog(Window owner) {
super(owner);
public LoadingDialog() {
super();
setResizable(false);
setTitle(ApplicationInfo.shortApplicationVerName);
Container cntp = getContentPane();

View File

@@ -111,7 +111,7 @@ public class Main {
private static List<SWFSourceInfo> sourceInfos = new ArrayList<>();
protected static LoadingDialog loadingDialog;
private static LoadingDialog loadingDialog;
public static ModeFrame modeFrame;
@@ -188,6 +188,23 @@ public class Main {
}
}
protected static LoadingDialog getLoadingDialog() {
if (loadingDialog == null) {
synchronized (Main.class) {
if (loadingDialog == null) {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
loadingDialog = new LoadingDialog();
}
});
}
}
}
return loadingDialog;
}
public static MainFrame getMainFrame() {
return mainFrame;
}
@@ -266,11 +283,11 @@ public class Main {
}
}
if (loadingDialog != null) {
loadingDialog.setDetail(name);
getLoadingDialog().setDetail(name);
if (percent == -1) {
loadingDialog.hidePercent();
getLoadingDialog().hidePercent();
} else {
loadingDialog.setPercent(percent);
getLoadingDialog().setPercent(percent);
}
}
if (CommandLineArgumentParser.isCommandLineMode()) {
@@ -290,7 +307,7 @@ public class Main {
mainFrame.getPanel().setWorkStatus("", null);
}
if (loadingDialog != null) {
loadingDialog.setDetail("");
getLoadingDialog().setDetail("");
}
}
});
@@ -482,7 +499,7 @@ public class Main {
}
}
loadingDialog.setVisible(false);
getLoadingDialog().setVisible(false);
shouldCloseWhenClosingLoadingDialog = false;
final SWF fswf = firstSWF;
@@ -524,8 +541,12 @@ public class Main {
debugDialog = null;
}
if (loadingDialog != null) {
loadingDialog.setVisible(false);
loadingDialog = null;
synchronized (Main.class) {
if (loadingDialog != null) {
loadingDialog.setVisible(false);
}
loadingDialog = null;
}
}
if (proxyFrame != null) {
proxyFrame.setVisible(false);
@@ -580,16 +601,7 @@ public class Main {
Helper.freeMem();
}
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) {
Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow());
}
}
});
Main.loadingDialog.setVisible(true);
getLoadingDialog().setVisible(true);
OpenFileWorker wrk = new OpenFileWorker(newSourceInfos);
wrk.execute();
sourceInfos.addAll(Arrays.asList(newSourceInfos));

View File

@@ -2306,10 +2306,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
public void loadFromBinaryTag(final List<DefineBinaryDataTag> binaryDataTags) {
if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) {
Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow());
}
Main.loadingDialog.setVisible(true);
Main.getLoadingDialog().setVisible(true);
Main.startWork(AppStrings.translate("work.reading.swf") + "...");
new Thread() {
@@ -2322,7 +2319,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
@Override
public void progress(int p) {
Main.loadingDialog.setPercent(p);
Main.getLoadingDialog().setPercent(p);
}
}, Configuration.parallelSpeedUp.get());
bswf.fileTitle = "(SWF Data)";
@@ -2336,7 +2333,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
//ignore
}
Main.loadingDialog.setVisible(false);
Main.getLoadingDialog().setVisible(false);
Main.stopWork();
}