Crash-Haertung: Delegat bei Programm-Sets abhaengen, send()-Pointer safe, Doku
This commit is contained in:
@@ -38,10 +38,19 @@ struct TerminalInputField: NSViewRepresentable {
|
||||
|
||||
func updateNSView(_ view: NSView, context: Context) {
|
||||
context.coordinator.onSubmit = onSubmit
|
||||
if let f = view as? NSTextField, f.stringValue != text {
|
||||
f.stringValue = text
|
||||
// Delegat während Programm-Sets abhängen: sonst feuert textDidChange synchron
|
||||
// zurück ins SwiftUI-State — mitten im Render -> Crash ("Modifying state
|
||||
// during view update"). User-Tippen läuft weiter über den Delegaten.
|
||||
if let f = view as? NSTextField {
|
||||
if f.stringValue != text {
|
||||
f.delegate = nil
|
||||
f.stringValue = text
|
||||
f.delegate = context.coordinator
|
||||
}
|
||||
} else if let tv = view as? NSTextView, tv.string != text {
|
||||
tv.delegate = nil
|
||||
tv.string = text
|
||||
tv.delegate = context.coordinator
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user