diff --git a/source/net/filebot/ui/rename/EpisodeListMatcher.java b/source/net/filebot/ui/rename/EpisodeListMatcher.java index 3cead5fa..fa0c29ba 100644 --- a/source/net/filebot/ui/rename/EpisodeListMatcher.java +++ b/source/net/filebot/ui/rename/EpisodeListMatcher.java @@ -161,9 +161,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher { synchronized (inputMemory) { List input = inputMemory.get(suggestion); if (input == null || suggestion == null || suggestion.isEmpty()) { - synchronized (parent) { - input = showMultiValueInputDialog(getQueryInputMessage("Please identify the following files:", "Enter series name:", files), suggestion, provider.getName(), parent); - } + input = showMultiValueInputDialog(getQueryInputMessage("Please identify the following files:", "Enter series name:", files), suggestion, provider.getName(), parent); inputMemory.put(suggestion, input); } @@ -279,7 +277,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher { } // allow only one select dialog at a time - synchronized (parent) { + synchronized (INPUT_DIALOG_LOCK) { SwingUtilities.invokeAndWait(showSelectDialog); SearchResult userSelection = showSelectDialog.get(); diff --git a/source/net/filebot/ui/rename/MovieMatcher.java b/source/net/filebot/ui/rename/MovieMatcher.java index 41b4177a..168c9f70 100644 --- a/source/net/filebot/ui/rename/MovieMatcher.java +++ b/source/net/filebot/ui/rename/MovieMatcher.java @@ -229,9 +229,7 @@ class MovieMatcher implements AutoCompleteMatcher { if (input == null || suggestion == null || suggestion.isEmpty()) { File movieFolder = guessMovieFolder(movieFile); - synchronized (parent) { - input = showInputDialog(getQueryInputMessage("Please identify the following files:", "Enter movie name:", movieFile), suggestion != null && suggestion.length() > 0 ? suggestion : getName(movieFile), movieFolder == null ? movieFile.getName() : String.join(" / ", movieFolder.getName(), movieFile.getName()), parent); - } + input = showInputDialog(getQueryInputMessage("Please identify the following files:", "Enter movie name:", movieFile), suggestion != null && suggestion.length() > 0 ? suggestion : getName(movieFile), movieFolder == null ? movieFile.getName() : String.join(" / ", movieFolder.getName(), movieFile.getName()), parent); inputMemory.put(suggestion, input); } @@ -391,7 +389,7 @@ class MovieMatcher implements AutoCompleteMatcher { return null; } - synchronized (parent) { + synchronized (INPUT_DIALOG_LOCK) { SwingUtilities.invokeAndWait(showSelectDialog); // cache selected value diff --git a/source/net/filebot/util/ui/SwingUI.java b/source/net/filebot/util/ui/SwingUI.java index 8d1cf570..0c171dd8 100644 --- a/source/net/filebot/util/ui/SwingUI.java +++ b/source/net/filebot/util/ui/SwingUI.java @@ -226,7 +226,7 @@ public final class SwingUI { return (frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0; } - public static List showMultiValueInputDialog(final Object message, final String initialValue, final String title, final Component parent) { + public static List showMultiValueInputDialog(Object message, String initialValue, String title, Component parent) { String input = showInputDialog(message, initialValue, title, parent); if (input == null || input.isEmpty()) { return emptyList(); @@ -252,15 +252,19 @@ public final class SwingUI { return singletonList(input); } - public static String showInputDialog(final Object message, final String initialValue, final String title, final Component parent) { - final StringBuilder buffer = new StringBuilder(); + public static final Object INPUT_DIALOG_LOCK = new Object(); - runOnEventDispatchThread(() -> { - Object value = JOptionPane.showInputDialog(parent, message, title, PLAIN_MESSAGE, null, null, initialValue); - if (value != null) { - buffer.append(value.toString().trim()); - } - }); + public static String showInputDialog(Object message, String initialValue, String title, Component parent) { + StringBuilder buffer = new StringBuilder(); + + synchronized (INPUT_DIALOG_LOCK) { + runOnEventDispatchThread(() -> { + Object value = JOptionPane.showInputDialog(parent, message, title, PLAIN_MESSAGE, null, null, initialValue); + if (value != null) { + buffer.append(value.toString().trim()); + } + }); + } return buffer.length() == 0 ? null : buffer.toString(); }