Skip to content

Commit

Permalink
fix(gui): attempt to resolve field rename issues with shortcut (#1440)…
Browse files Browse the repository at this point in the history
…(PR#2075)

This is an attempt to fix the issues that sometimes arise when renaming functions or variables using the "n" shortcut as stated in issue #1440.

The reasoning behind the change: The instance creation of the RenameDialog was somehow affecting the UI thread and not allowing for the key release event to be dispatched. By running everything inside the invokeLater block, this might get fixed as it will execute after all previous tasks are finished.
We now also only show the dialog after EVERYTHING is set up, not before.
  • Loading branch information
iscle authored Jan 5, 2024
1 parent faeae08 commit 23e643c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jadx-gui/src/main/java/jadx/gui/ui/dialog/RenameDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -42,9 +43,11 @@ public class RenameDialog extends JDialog {
private transient JButton renameBtn;

public static boolean rename(MainWindow mainWindow, JRenameNode node) {
RenameDialog renameDialog = new RenameDialog(mainWindow, node);
UiUtils.uiRun(() -> renameDialog.setVisible(true));
UiUtils.uiRun(renameDialog::initRenameField); // wait for UI events to propagate
SwingUtilities.invokeLater(() -> {
RenameDialog renameDialog = new RenameDialog(mainWindow, node);
renameDialog.initRenameField();
renameDialog.setVisible(true);
});
return true;
}

Expand Down

0 comments on commit 23e643c

Please sign in to comment.