Skip to content
Permalink
Browse files

Merge branch 'ekstasis-new_audio_filter_bug' into develop

  • Loading branch information...
lhc70000 committed Mar 30, 2019
2 parents 61f112f + dffd4a6 commit 5fa6401357285a1b08b9fdefcebf637200e8d75c
Showing with 19 additions and 1 deletion.
  1. +1 −0 iina/Base.lproj/FilterWindowController.xib
  2. +18 −1 iina/FilterWindowController.swift
@@ -211,6 +211,7 @@ Gw
</window>
<viewController id="bda-X5-kCJ" customClass="NewFilterSheetViewController" customModule="IINA" customModuleProvider="target">
<connections>
<outlet property="addButton" destination="THV-Yh-VnK" id="GeO-qk-FbF"/>
<outlet property="filterWindow" destination="-2" id="Pjr-CT-nJA"/>
<outlet property="scrollContentView" destination="ZHP-RK-Ly4" id="NhJ-gL-sPY"/>
<outlet property="tableView" destination="n0t-vk-dME" id="IBk-xT-LkA"/>
@@ -299,7 +299,8 @@ class NewFilterSheetViewController: NSViewController, NSTableViewDelegate, NSTab
@IBOutlet weak var filterWindow: FilterWindowController!
@IBOutlet weak var tableView: NSTableView!
@IBOutlet weak var scrollContentView: NSView!

@IBOutlet weak var addButton: NSButton!

private var currentPreset: FilterPreset?
private var currentBindings: [String: NSControl] = [:]
private var presets: [FilterPreset] = []
@@ -328,11 +329,18 @@ class NewFilterSheetViewController: NSViewController, NSTableViewDelegate, NSTab
currentPreset = preset
currentBindings.removeAll()
scrollContentView.subviews.forEach { $0.removeFromSuperview() }
addButton.isEnabled = true

var maxY: CGFloat = 0
let generateInputs: (String, FilterParameter) -> Void = { (name, param) in
self.scrollContentView.addSubview(self.quickLabel(yPos: maxY, title: preset.localizedParamName(name)))
maxY += 21
let input = self.quickInput(yPos: &maxY, param: param)
// For preventing crash due to adding a filter with no name:
if name == "name", preset.name.starts(with: "custom_"), let textField = input as? NSTextField {
textField.delegate = self
self.addButton.isEnabled = !textField.stringValue.isEmpty
}
self.scrollContentView.addSubview(input)
self.currentBindings[name] = input
}
@@ -442,3 +450,12 @@ class NewFilterSheetViewController: NSViewController, NSTableViewDelegate, NSTab
}

}

/* For preventing crash due to to adding filter with no name */
extension NewFilterSheetViewController: NSTextFieldDelegate {
func controlTextDidChange(_ obj: Notification) {
if let textField = obj.object as? NSTextField {
self.addButton.isEnabled = !textField.stringValue.isEmpty
}
}
}

0 comments on commit 5fa6401

Please sign in to comment.
You can’t perform that action at this time.