Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #119 from Shufflepuck/hotfix/main-window-not-launc…
Browse files Browse the repository at this point in the history
…hing

Fix main window not showing
  • Loading branch information
damien-rivet committed May 31, 2019
2 parents 4d13a9e + 74c2021 commit cc795d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
8 changes: 0 additions & 8 deletions Sources/Views/Main/Base.lproj/SplashBuddy.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@
<constraint firstItem="SdF-5b-Pla" firstAttribute="top" secondItem="VI7-LS-rJR" secondAttribute="top" id="f0G-pr-kb9"/>
<constraint firstAttribute="bottom" secondItem="SdF-5b-Pla" secondAttribute="bottom" id="mSG-zm-sdE"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
<color key="value" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="4"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<connections>
<outlet property="continueButton" destination="k7a-CL-x2G" id="7B2-Pa-6MA"/>
Expand Down
30 changes: 18 additions & 12 deletions Sources/Views/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class MainViewController: NSViewController, NSTableViewDataSource {

// Display Alert if /var/log/jamf.log doesn't exist
guard Preferences.sharedInstance.logFileHandle != nil else {
if let currentWindow = self.view.window {
if let currentWindow = view.window {
let alert = NSAlert()

alert.alertStyle = .critical
Expand All @@ -211,9 +211,11 @@ class MainViewController: NSViewController, NSTableViewDataSource {
return
}

DispatchQueue.main.async { [unowned self] in
self.sendButton.isHidden = false
self.continueButton.isHidden = true
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }

strongSelf.sendButton.isHidden = false
strongSelf.continueButton.isHidden = true
}

webView.loadFileURL(form, allowingReadAccessTo: Preferences.sharedInstance.assetPath)
Expand All @@ -226,8 +228,10 @@ class MainViewController: NSViewController, NSTableViewDataSource {
Log.write(string: "Form already completed.", cat: "UserInput", level: .debug)
}

DispatchQueue.main.async { [unowned self] in
self.continueButton.isHidden = Preferences.sharedInstance.continueAction.isHidden
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }

strongSelf.continueButton.isHidden = Preferences.sharedInstance.continueAction.isHidden
}

webView.loadFileURL(html, allowingReadAccessTo: Preferences.sharedInstance.assetPath)
Expand Down Expand Up @@ -268,7 +272,9 @@ class MainViewController: NSViewController, NSTableViewDataSource {
}

@IBAction func evalForm(_ sender: Any) {
webView.evaluateJavaScript(evaluationJavascript) { (data: Any?, error: Error?) in
webView.evaluateJavaScript(evaluationJavascript) { [weak self] (data: Any?, error: Error?) in
guard let strongSelf = self else { return }

if error != nil {
Log.write(string: "Error getting User Input", cat: "UserInput", level: .error)
return
Expand All @@ -293,14 +299,14 @@ class MainViewController: NSViewController, NSTableViewDataSource {
FileManager.default.createFile(atPath: "\(item.key).txt", contents: (item.value as? String ?? "").data(using: .utf8), attributes: nil)
}

DispatchQueue.main.async { [unowned self] in
self.sendButton.isHidden = true
self.continueButton.isHidden = false
DispatchQueue.main.async {
strongSelf.sendButton.isHidden = true
strongSelf.continueButton.isHidden = false

if let html = Preferences.sharedInstance.html {
self.webView.loadFileURL(html, allowingReadAccessTo: Preferences.sharedInstance.assetPath)
strongSelf.webView.loadFileURL(html, allowingReadAccessTo: Preferences.sharedInstance.assetPath)
} else {
self.webView.loadHTMLString(NSLocalizedString("error.create_missing_bundle"), baseURL: nil)
strongSelf.webView.loadHTMLString(NSLocalizedString("error.create_missing_bundle"), baseURL: nil)
}
}

Expand Down
13 changes: 13 additions & 0 deletions SplashBuddy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ED797C93229E6C8A00505E8C /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED797C92229E6C8A00505E8C /* Tools.swift */; };
ED797C95229E6EFB00505E8C /* ToolsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED797C94229E6EFB00505E8C /* ToolsTests.swift */; };
ED797C99229E6FCF00505E8C /* SoftwareTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED797C98229E6FCF00505E8C /* SoftwareTests.swift */; };
EDA7F21922A1628300C41354 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDA7F21822A1628300C41354 /* WebKit.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -132,13 +133,15 @@
EDA78DAD20A03D2D00BBA14E /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
EDA78DAE20A03D2D00BBA14E /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
EDA78DAF20A03D2D00BBA14E /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/SplashBuddy.strings; sourceTree = "<group>"; };
EDA7F21822A1628300C41354 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
089D291A1D50D12200E58C6D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EDA7F21922A1628300C41354 /* WebKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -161,6 +164,7 @@
089D291F1D50D12200E58C6D /* Sources */,
08AC4F751D520A3200CAB019 /* SplashBuddyTestAssets */,
089D292F1D50D12200E58C6D /* Tests */,
EDA7F21722A1628300C41354 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -398,6 +402,14 @@
path = Tools;
sourceTree = "<group>";
};
EDA7F21722A1628300C41354 /* Frameworks */ = {
isa = PBXGroup;
children = (
EDA7F21822A1628300C41354 /* WebKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -773,6 +785,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Configurations/SplashBuddyTests.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
Expand Down

0 comments on commit cc795d3

Please sign in to comment.