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