From c7adf8ba9abb1483566abf3b6f93db46984c0380 Mon Sep 17 00:00:00 2001 From: Christian Tietze Date: Mon, 5 Jun 2023 14:24:32 +0200 Subject: [PATCH 1/2] add assert message --- Sources/WebMIDIKit/MIDIPortMap.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/WebMIDIKit/MIDIPortMap.swift b/Sources/WebMIDIKit/MIDIPortMap.swift index 3bdb1c5..60e7fa1 100644 --- a/Sources/WebMIDIKit/MIDIPortMap.swift +++ b/Sources/WebMIDIKit/MIDIPortMap.swift @@ -57,7 +57,7 @@ public class MIDIPortMap: Collection { if port.isVirtual { return self[port.id]! } else { - assert(self[port.id] == nil) + assert(self[port.id] == nil, "Port with ID \(port.id) should not exist, yet") self[port.id] = port return port } From ece91df101d4cc325c9057e989ec1191ccf73a9c Mon Sep 17 00:00:00 2001 From: Christian Tietze Date: Mon, 5 Jun 2023 14:24:39 +0200 Subject: [PATCH 2/2] remove crashing assertions on 'remove' --- Sources/WebMIDIKit/MIDIPortMap.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/WebMIDIKit/MIDIPortMap.swift b/Sources/WebMIDIKit/MIDIPortMap.swift index 60e7fa1..88e9688 100644 --- a/Sources/WebMIDIKit/MIDIPortMap.swift +++ b/Sources/WebMIDIKit/MIDIPortMap.swift @@ -66,8 +66,7 @@ public class MIDIPortMap: Collection { internal final func remove(_ endpoint: MIDIEndpoint) -> Value? { // disconnect? - guard let port = self[endpoint] else { assert(false); return nil } - assert(port.state == .connected) + guard let port = self[endpoint] else { return nil } self[port.id] = nil return port }