Fix a crash that happened when addTracks was called before windowDidLoad
This commit is contained in:
2 files changed
+22
-16
No files matched your search
@@ -8,8 +8,7 @@
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="FileImportController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="addButton" destination="25" id="Nec-Ur-WuH"/>
|
||||
<outlet property="importMetadata" destination="36" id="ctf-Cj-LBY"/>
|
||||
<outlet property="importMetadataCheckbox" destination="36" id="ctf-Cj-LBY"/>
|
||||
<outlet property="tableView" destination="7" id="fqn-pa-2UI"/>
|
||||
<outlet property="window" destination="1" id="3"/>
|
||||
</connections>
|
||||
@@ -307,7 +306,7 @@
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="25">
|
||||
<rect key="frame" x="548" y="13" width="82" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="28">
|
||||
<buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="28">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
@@ -337,6 +336,9 @@ Gw
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="setImportMetadata:" target="-2" id="Dsh-Uq-duE"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
@@ -358,7 +360,7 @@ Gw
|
||||
<constraint firstItem="26" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="xcH-VR-g52"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<point key="canvasLocation" x="137" y="103"/>
|
||||
<point key="canvasLocation" x="-115" y="98"/>
|
||||
</window>
|
||||
<menu id="Nqo-5L-aDh">
|
||||
<items>
|
||||
|
||||
@@ -13,9 +13,6 @@ protocol FileImportControllerDelegate : AnyObject {
|
||||
|
||||
class FileImportController: NSWindowController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
|
||||
private let metadata: MP42Metadata?
|
||||
private let items: [ItemType]
|
||||
|
||||
private enum ItemType {
|
||||
case file(MP42FileImporter)
|
||||
case track(Settings)
|
||||
@@ -163,13 +160,16 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var tableView: SBTableView!
|
||||
@IBOutlet weak var importMetadata: NSButton!
|
||||
@IBOutlet weak var addButton: NSButton!
|
||||
|
||||
|
||||
private let metadata: MP42Metadata?
|
||||
private let items: [ItemType]
|
||||
|
||||
private var importMetadata: Bool
|
||||
private weak var delegate: FileImportControllerDelegate?
|
||||
|
||||
|
||||
@IBOutlet weak var tableView: SBTableView!
|
||||
@IBOutlet weak var importMetadataCheckbox: NSButton!
|
||||
|
||||
override public var windowNibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "FileImportController")
|
||||
}
|
||||
@@ -190,6 +190,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
||||
|
||||
self.metadata = fileImporters.first?.metadata
|
||||
self.items = rows
|
||||
self.importMetadata = metadata != nil
|
||||
|
||||
super.init(window: nil)
|
||||
}
|
||||
@@ -201,8 +202,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
self.importMetadata.isEnabled = metadata != nil
|
||||
self.addButton.isEnabled = true
|
||||
self.importMetadataCheckbox.isEnabled = importMetadata
|
||||
}
|
||||
|
||||
// MARK: Public properties
|
||||
@@ -361,13 +361,17 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
||||
}
|
||||
|
||||
delegate?.didSelect(tracks: selectedTracks,
|
||||
metadata: importMetadata.state == NSControl.StateValue.on ? metadata : nil)
|
||||
metadata: importMetadata ? metadata : nil)
|
||||
|
||||
window?.sheetParent?.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func setImportMetadata(_ sender: NSButton) {
|
||||
importMetadata = sender.state == NSControl.StateValue.on
|
||||
}
|
||||
|
||||
@IBAction func setCheck(_ sender: NSButton) {
|
||||
let row = tableView.row(for: sender)
|
||||
if row == -1 { return }
|
||||
|
||||
Reference in new issue
Block a user