From 04683f0cb8ed9126b946615576d0b9b13d2e6bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 28 Jan 2021 06:38:24 +0100 Subject: [PATCH] Fixed: Improper initialization of ActiveX component when Flash not available causing FFDec not start --- CHANGELOG.md | 1 + .../decompiler/flash/gui/MainFrameRibbon.java | 11 ++-- .../flash/gui/player/FlashPlayerPanel.java | 50 +++++++++---------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fd8ff67..7baffa6cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - Graph dialog scroll speed increased - AS3: return in finally - AS3 docs not correctly displayed under p-code when metadata present +- Improper initialization of ActiveX component when Flash not available causing FFDec not start ### Changed - AS3 test methods separated to classes diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 603747b56..98d917642 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -53,10 +53,13 @@ public final class MainFrameRibbon extends AppRibbonFrame { FlashPlayerPanel flashPanel = null; FlashPlayerPanel flashPanel2 = null; - try { - flashPanel = new FlashPlayerPanel(this); - flashPanel2 = new FlashPlayerPanel(this); - } catch (FlashUnsupportedException fue) { + if (Configuration.useAdobeFlashPlayerForPreviews.get()) { + try { + flashPanel = new FlashPlayerPanel(this); + flashPanel2 = new FlashPlayerPanel(this); + } catch (FlashUnsupportedException fue) { + //ignored + } } Container cnt = getContentPane(); diff --git a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 53458bbf8..5cd697b86 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -178,36 +178,36 @@ public final class FlashPlayerPanel extends Panel implements Closeable, MediaDis // hack: Kernel32.INSTANCE.ConnectNamedPipe never completes in ActiveXControl static constructor flash = CancellableWorker.call(callable, 5, TimeUnit.SECONDS); + + flash.setAllowScriptAccess("always"); + try { + flash.setAllowNetworking("all"); + } catch (ActiveXException ex) { + // ignore + } + + flash.addOnReadyStateChangeListener((ActiveXEvent axe) -> { + fireMediaDisplayStateChanged(); + }); + + flash.addFlashCallListener((ActiveXEvent axe) -> { + String req = (String) axe.args.get("request"); + Matcher m = Pattern.compile("(.*)").matcher(req); + if (m.matches()) { + String funname = m.group(1); + String msg = m.group(2); + if (funname.equals("alert") || funname.equals("console.log")) { + if (Main.debugDialog != null) { + Main.debugDialog.log(funname + ":" + msg); + } + } + } + }); } catch (ActiveXException | TimeoutException | InterruptedException | ExecutionException ex) { logger.log(Level.WARNING, "Cannot initialize flash panel", ex); throw new FlashUnsupportedException(); } - flash.setAllowScriptAccess("always"); - try { - flash.setAllowNetworking("all"); - } catch (ActiveXException ex) { - // ignore - } - - flash.addOnReadyStateChangeListener((ActiveXEvent axe) -> { - fireMediaDisplayStateChanged(); - }); - - flash.addFlashCallListener((ActiveXEvent axe) -> { - String req = (String) axe.args.get("request"); - Matcher m = Pattern.compile("(.*)").matcher(req); - if (m.matches()) { - String funname = m.group(1); - String msg = m.group(2); - if (funname.equals("alert") || funname.equals("console.log")) { - if (Main.debugDialog != null) { - Main.debugDialog.log(funname + ":" + msg); - } - } - } - }); - timer = new Timer(); timer.schedule(new TimerTask() { private boolean isPlaying = false;