mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-08 20:39:44 -05:00
Make sure to not lock on Swing / AWT Window object
@see https://www.filebot.net/forums/viewtopic.php?f=11&t=5259&p=29747#p35519
This commit is contained in:
parent
aa8125e7e4
commit
b9572f4501
@ -161,9 +161,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||
synchronized (inputMemory) {
|
||||
List<String> 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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -226,7 +226,7 @@ public final class SwingUI {
|
||||
return (frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
|
||||
}
|
||||
|
||||
public static List<String> showMultiValueInputDialog(final Object message, final String initialValue, final String title, final Component parent) {
|
||||
public static List<String> 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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user