From 6f7c986226abafcc4b403e5577d0c64d4e9fc8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 20 Dec 2022 22:00:09 +0100 Subject: [PATCH] Fixed Image flickering --- CHANGELOG.md | 1 + .../decompiler/flash/gui/ImagePanel.java | 39 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5bc9547..f141a2cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - AS3 direct editation and decompiler share same AbcIndex - BUTTONRECORD display does not use its Matrix - Editation status not cleared after Sprite transforming +- Image flickering ### Changed - Warning before switching deobfuscation is now optional diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 775f0acce..22bf13f14 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -252,7 +252,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private RegistrationPointPosition registrationPointPosition = RegistrationPointPosition.CENTER; private DepthState depthStateUnderCursor = null; - + private List placeObjectSelectedListeners = new ArrayList<>(); private static Cursor loadCursor(String name, int x, int y) throws IOException { @@ -268,22 +268,22 @@ public final class ImagePanel extends JPanel implements MediaDisplay { public void addBoundsChangeListener(BoundsChangeListener listener) { boundsChangeListeners.add(listener); } - + public void addPlaceObjectSelectedListener(ActionListener listener) { placeObjectSelectedListeners.add(listener); } - + public void removePlaceObjectSelectedListener(ActionListener listener) { placeObjectSelectedListeners.remove(listener); } - + private void firePlaceObjectSelected() { ActionEvent e = new ActionEvent(this, 0, ""); - for (ActionListener listener:placeObjectSelectedListeners) { + for (ActionListener listener : placeObjectSelectedListeners) { listener.actionPerformed(e); } } - + public PlaceObjectTypeTag getPlaceTagUnderCursor() { if (depthStateUnderCursor == null) { return null; @@ -655,14 +655,13 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } private boolean ctrlDown = false; - + private boolean altDown = false; public boolean isAltDown() { return altDown; } - - + public IconPanel() { KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); @@ -1427,15 +1426,18 @@ public final class ImagePanel extends JPanel implements MediaDisplay { public synchronized void setImg(SerializableImage img) { this._img = img; calcRect(); - render(); - repaint(); + View.execInEventDispatchLater(new Runnable() { + @Override + public void run() { + render(); + repaint(); + } + }); + } private void setAllowMove(boolean allowMove) { - this.allowMove = allowMove; - /*if (!allowMove) { - offsetPoint = new Point(); - }*/ + this.allowMove = allowMove; } private void calcRect() { @@ -1519,7 +1521,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (ri != null) { g2d.drawImage(ri, 0, 0, null); } - } + } if (Configuration._debugMode.get()) { g2d.setColor(Color.red); @@ -2391,10 +2393,9 @@ public final class ImagePanel extends JPanel implements MediaDisplay { return; } - synchronized (ImagePanel.this) { + /*synchronized (ImagePanel.this) { iconPanel.calcRect(); - } - + }*/ RenderContext renderContext = new RenderContext(); renderContext.displayObjectCache = displayObjectCache; if (cursorPosition != null && freeTransformDepth == -1) {