From c6099ddb58f7c2c60598652cfc87a42197b3809d Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 28 Aug 2014 19:06:22 +0000 Subject: [PATCH] * fixfix --- source/net/filebot/mac/DropToUnlock.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/net/filebot/mac/DropToUnlock.java b/source/net/filebot/mac/DropToUnlock.java index 0a89f67f..5d1492ee 100644 --- a/source/net/filebot/mac/DropToUnlock.java +++ b/source/net/filebot/mac/DropToUnlock.java @@ -23,12 +23,14 @@ 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.util.Collection; 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; @@ -182,17 +184,21 @@ public class DropToUnlock extends JList { // show dialog on EDT and wait for user input try { - SwingUtilities.invokeAndWait(showPermissionDialog); + if (SwingUtilities.isEventDispatchThread()) { + showPermissionDialog.run(); + } else { + SwingUtilities.invokeAndWait(showPermissionDialog); + } // store security-scoped bookmark if dialog was accepted if (showPermissionDialog.get()) { storeSecurityScopedBookmarks(model); return true; } - } catch (Exception e) { - Logger.getLogger(DropToUnlock.class.getName()).log(Level.WARNING, "NSURL.bookmarkDataWithOptions: " + e.toString()); + return false; + } catch (InterruptedException | InvocationTargetException | ExecutionException e) { + throw new RuntimeException("Failed to request permissions: " + e.getMessage(), e); } - return false; } public DropToUnlock(Collection model) {