Skip to content

Commit

Permalink
Merge pull request #9 from bow-swift/open-dialog-bug
Browse files Browse the repository at this point in the history
fix bug in OpenPanel
  • Loading branch information
miguelangel-dev authored Oct 23, 2019
2 parents f4e044f + d50fd96 commit 9899e8a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
22 changes: 13 additions & 9 deletions nef-plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
8B50B4A1234C8FBC00C2429D /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B50B4A0234C8FBC00C2429D /* Reachability.swift */; };
8B7E0622235493F7003ED8E2 /* NSWindow+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E0621235493F7003ED8E2 /* NSWindow+Extension.swift */; };
8B7E0624235498CA003ED8E2 /* OutputFolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E0623235498CA003ED8E2 /* OutputFolderView.swift */; };
8B91B1932360A3690041F79B /* DispatchGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B91B1922360A3690041F79B /* DispatchGroup.swift */; };
8B9F3CEF22EF2D48001EE2DF /* CarbonWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B9F3CEE22EF2D48001EE2DF /* CarbonWebView.swift */; };
8B9F3CF122F036BD001EE2DF /* CarbonViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B9F3CF022F036BD001EE2DF /* CarbonViewer.swift */; };
8B9F3CF322F036E3001EE2DF /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B9F3CF222F036E3001EE2DF /* LoadingView.swift */; };
Expand Down Expand Up @@ -89,6 +90,7 @@
8B50B4A0234C8FBC00C2429D /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
8B7E0621235493F7003ED8E2 /* NSWindow+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSWindow+Extension.swift"; sourceTree = "<group>"; };
8B7E0623235498CA003ED8E2 /* OutputFolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutputFolderView.swift; sourceTree = "<group>"; };
8B91B1922360A3690041F79B /* DispatchGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchGroup.swift; sourceTree = "<group>"; };
8B9F3CEE22EF2D48001EE2DF /* CarbonWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbonWebView.swift; sourceTree = "<group>"; };
8B9F3CF022F036BD001EE2DF /* CarbonViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbonViewer.swift; sourceTree = "<group>"; };
8B9F3CF222F036E3001EE2DF /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -164,9 +166,10 @@
8B3B21A822F8328B00E92BC9 /* Utils */ = {
isa = PBXGroup;
children = (
8BEAFB11235C96F700118F31 /* Bookmark.swift */,
8B3B21A922F8329900E92BC9 /* Browser.swift */,
8B91B1922360A3690041F79B /* DispatchGroup.swift */,
8BF9220523546D8D00C58AA0 /* OpenPanel.swift */,
8BEAFB11235C96F700118F31 /* Bookmark.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -436,6 +439,7 @@
files = (
8B2CE74622D89C8900571F24 /* CheckOptionView.swift in Sources */,
8B9F3CF522F03704001EE2DF /* NSView+Layout.swift in Sources */,
8B91B1932360A3690041F79B /* DispatchGroup.swift in Sources */,
8B7E0622235493F7003ED8E2 /* NSWindow+Extension.swift in Sources */,
8BF68FB322DE2154009E57A9 /* PreferencesViewModel.swift in Sources */,
8B4D1E1522D7A37E004432CF /* PickerOptionView.swift in Sources */,
Expand Down Expand Up @@ -638,15 +642,15 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
INFOPLIST_FILE = "nef/Support Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.fortysevendeg.nef;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)App";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -664,15 +668,15 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
INFOPLIST_FILE = "nef/Support Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.fortysevendeg.nef;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)App";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -688,7 +692,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
INFOPLIST_FILE = "nef-plugin/Support Files/Info.plist";
Expand All @@ -698,7 +702,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.fortysevendeg.nef-plugin";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -713,7 +717,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
INFOPLIST_FILE = "nef-plugin/Support Files/Info.plist";
Expand All @@ -723,7 +727,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.fortysevendeg.nef-plugin";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
20 changes: 20 additions & 0 deletions nef/Utils/DispatchGroup.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © 2019 The nef Authors.

import Foundation


func runSync<T>(on queue: DispatchQueue = .main, block: @escaping () -> T?) -> T? {
guard !DispatchQueue.isMainThread else { return block() }
return queue.sync { block() }
}


extension DispatchQueue {
public static var currentLabel: String {
return String(validatingUTF8: __dispatch_queue_get_label(nil)) ?? ""
}

public static var isMainThread: Bool {
currentLabel == "com.apple.main-thread"
}
}
9 changes: 5 additions & 4 deletions nef/Utils/OpenPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ class OpenPanel {

// MARK: private methods
private func runUserSelectionModal() -> URL? {
guard dialog.runModal() == .OK,
let selection = dialog.url else { return nil }

return selection
runSync {
guard self.dialog.runModal() == .OK,
let url = self.dialog.url else { return nil }
return url
}
}

// MARK: constants
Expand Down

0 comments on commit 9899e8a

Please sign in to comment.