From cc98e1bc6ab3ade7155eaffca2eb87dcc52ed528 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Fri, 24 Jun 2022 21:02:50 +0200 Subject: [PATCH] fix: reset the process lock when clearing the process view (#977) --- Kit/helpers.swift | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Kit/helpers.swift b/Kit/helpers.swift index 46dfc2ad..fd777b55 100644 --- a/Kit/helpers.swift +++ b/Kit/helpers.swift @@ -771,16 +771,7 @@ public class ProcessView: NSStackView { } public override func mouseDown(with: NSEvent) { - self.lock = !self.lock - if self.lock { - self.imageView.isHidden = true - self.killView.isHidden = false - self.layer?.backgroundColor = .init(gray: 0.01, alpha: 0.1) - } else { - self.imageView.isHidden = false - self.killView.isHidden = true - self.layer?.backgroundColor = .none - } + self.setLock(!self.lock) } public func set(_ process: TopProcess, _ value: String) { @@ -798,9 +789,23 @@ public class ProcessView: NSStackView { self.valueView.stringValue = "" self.imageView.image = nil self.pid = nil + self.setLock(false) self.toolTip = "" } + private func setLock(_ state: Bool) { + self.lock = state + if self.lock { + self.imageView.isHidden = true + self.killView.isHidden = false + self.layer?.backgroundColor = .init(gray: 0.01, alpha: 0.1) + } else { + self.imageView.isHidden = false + self.killView.isHidden = true + self.layer?.backgroundColor = .none + } + } + @objc public func kill() { if let pid = self.pid { asyncShell("kill \(pid)")