Skip to content

Commit 08445ee

Browse files
committed
Strongly Reference Self in Monitor
1 parent 9ad415c commit 08445ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/CodeEditSourceEditor/Find/PanelView/FindPanel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ final class FindPanel: NSView {
5959
}
6060
}
6161

62+
deinit {
63+
removeEventMonitor()
64+
}
65+
6266
required init?(coder: NSCoder) {
6367
fatalError("init(coder:) has not been implemented")
6468
}
@@ -82,9 +86,9 @@ final class FindPanel: NSView {
8286
// MARK: - Event Monitor Management
8387

8488
func addEventMonitor() {
85-
eventMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event -> NSEvent? in
89+
eventMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { event -> NSEvent? in
8690
if event.keyCode == 53 { // if esc pressed
87-
self?.dismiss()
91+
self.dismiss()
8892
return nil // do not play "beep" sound
8993
}
9094
return event

0 commit comments

Comments
 (0)