From 3a580c774bfff2042797e1160344d815bbba28b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 28 Sep 2023 17:30:29 +0200 Subject: [PATCH] Allow to cancel exports before exporting assets --- .../exporters/script/AS3ScriptExporter.java | 23 +++++++++++++++++-- .../exporters/script/ExportPackTask.java | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index 18a14c762..d65df06a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -475,6 +475,11 @@ public class AS3ScriptExporter { } if (exportSettings.exportEmbedFlaMode || exportSettings.exportEmbed) { + + if (Thread.currentThread().isInterrupted()) { + return ret; + } + final String ASSETS_DIR = outdir + "/_assets/"; List exportTagList = new ArrayList<>(); List spriteTagList = new ArrayList<>(); @@ -517,15 +522,29 @@ public class AS3ScriptExporter { try { BinaryDataExporter bde = new BinaryDataExporter(); bde.exportBinaryData(handler, ASSETS_DIR, rttl, new BinaryDataExportSettings(BinaryDataExportMode.RAW), evl); + if (Thread.currentThread().isInterrupted()) { + return ret; + } ImageExporter ie = new ImageExporter(); ie.exportImages(handler, ASSETS_DIR, rttl, new ImageExportSettings(ImageExportMode.PNG_GIF_JPEG), evl); + if (Thread.currentThread().isInterrupted()) { + return ret; + } SoundExporter se = new SoundExporter(); se.exportSounds(handler, ASSETS_DIR, rttl, new SoundExportSettings(SoundExportMode.MP3_WAV), evl); + if (Thread.currentThread().isInterrupted()) { + return ret; + } FontExporter fe = new FontExporter(); fe.exportFonts(handler, ASSETS_DIR, rttl, new FontExportSettings(FontExportMode.TTF), evl); + if (Thread.currentThread().isInterrupted()) { + return ret; + } Font4Exporter f4e = new Font4Exporter(); f4e.exportFonts(handler, ASSETS_DIR, rttl, new Font4ExportSettings(Font4ExportMode.CFF), evl); - + if (Thread.currentThread().isInterrupted()) { + return ret; + } if (!spriteTagList.isEmpty()) { new RetryTask(() -> { try (FileOutputStream fos = new FileOutputStream(ASSETS_DIR + "/assets.swf")) { @@ -593,7 +612,7 @@ public class AS3ScriptExporter { } catch (IOException ex) { Logger.getLogger(AS3ScriptExporter.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { - Logger.getLogger(AS3ScriptExporter.class.getName()).log(Level.SEVERE, null, ex); + return ret; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/ExportPackTask.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/ExportPackTask.java index 66cac64ce..4f349208b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/ExportPackTask.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/ExportPackTask.java @@ -77,7 +77,7 @@ public class ExportPackTask implements Callable { RunnableIOExResult rio = new RunnableIOExResult() { @Override public void run() throws IOException, InterruptedException { - startTime = System.currentTimeMillis(); + startTime = System.currentTimeMillis(); this.result = pack.export(abcIndex, file, exportSettings, parallel); stopTime = System.currentTimeMillis(); }