mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
Fix Mac sandbox issues
This commit is contained in:
parent
4debb73ffc
commit
87125a98a9
@ -18,6 +18,8 @@ import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.SecondaryLoop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -25,7 +27,6 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.Collection;
|
||||
@ -33,10 +34,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -136,13 +133,13 @@ public class DropToUnlock extends JList<File> {
|
||||
return true;
|
||||
}
|
||||
|
||||
// show selection dialog on EDT
|
||||
RunnableFuture<Boolean> showPermissionDialog = new FutureTask<Boolean>(new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
final JDialog dialog = new JDialog(owner);
|
||||
// show dialog on EDT and wait for user input
|
||||
final SecondaryLoop secondaryLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
|
||||
final AtomicBoolean dialogCancelled = new AtomicBoolean(true);
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
JDialog dialog = new JDialog(owner);
|
||||
DropToUnlock d = new DropToUnlock(model) {
|
||||
|
||||
@Override
|
||||
@ -194,30 +191,21 @@ public class DropToUnlock extends JList<File> {
|
||||
|
||||
// show and wait for user input
|
||||
dialog.setVisible(true);
|
||||
|
||||
// abort if user has closed the window before all folders have been unlocked
|
||||
return !dialogCancelled.get();
|
||||
} finally {
|
||||
secondaryLoop.exit();
|
||||
}
|
||||
});
|
||||
|
||||
// show dialog on EDT and wait for user input
|
||||
try {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
showPermissionDialog.run();
|
||||
} else {
|
||||
SwingUtilities.invokeAndWait(showPermissionDialog);
|
||||
if (!secondaryLoop.enter()) {
|
||||
throw new IllegalStateException("SecondaryLoop.enter()");
|
||||
}
|
||||
if (dialogCancelled.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// store security-scoped bookmark if dialog was accepted
|
||||
if (showPermissionDialog.get()) {
|
||||
storeSecurityScopedBookmarks(model);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (InterruptedException | InvocationTargetException | ExecutionException e) {
|
||||
throw new RuntimeException("Failed to request permissions: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public DropToUnlock(Collection<File> model) {
|
||||
super(model.toArray(new File[0]));
|
||||
|
@ -86,7 +86,7 @@ public class MacAppUtilities {
|
||||
|
||||
// Enter the loop to block the current event handler, but leave UI responsive
|
||||
if (!secondaryLoop.enter()) {
|
||||
throw new RuntimeException("SecondaryLoop.enter()");
|
||||
throw new IllegalStateException("SecondaryLoop.enter()");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -185,7 +185,6 @@ public class SubtitleUploadDialog extends JDialog {
|
||||
protected void done() {
|
||||
try {
|
||||
List<SubtitleSearchResult> options = get();
|
||||
System.out.println(options);
|
||||
if (options.size() > 0) {
|
||||
SelectDialog<Movie> dialog = new SelectDialog<Movie>(SubtitleUploadDialog.this, options);
|
||||
dialog.setLocation(getOffsetLocation(dialog.getOwner()));
|
||||
|
Loading…
Reference in New Issue
Block a user