diff --git a/ModuleKit/Widgets/popup.swift b/ModuleKit/Widgets/popup.swift index 052dbf48..c90fd63b 100644 --- a/ModuleKit/Widgets/popup.swift +++ b/ModuleKit/Widgets/popup.swift @@ -71,7 +71,7 @@ internal class Popup: NSView { values.forEach { (s: Sensor_t) in if self.list[s.key] != nil { DispatchQueue.main.async(execute: { - if self.window!.isVisible { + if (self.window?.isVisible ?? false) { self.list[s.key]?.stringValue = s.formattedValue } }) diff --git a/Modules/CPU/popup.swift b/Modules/CPU/popup.swift index a0b8633e..8211f053 100644 --- a/Modules/CPU/popup.swift +++ b/Modules/CPU/popup.swift @@ -99,7 +99,7 @@ internal class Popup: NSView { var temperature: String = "Unknown" DispatchQueue.main.async(execute: { - if self.window!.isVisible || !self.ready { + if (self.window?.isVisible ?? false) || !self.ready { if tempValue != nil { let formatter = MeasurementFormatter() let measurement = Measurement(value: tempValue!.rounded(toPlaces: 0), unit: UnitTemperature.celsius) @@ -107,7 +107,7 @@ internal class Popup: NSView { } self.temperatureField?.stringValue = temperature - + self.systemField?.stringValue = "\(Int(value.systemLoad.rounded(toPlaces: 2) * 100)) %" self.userField?.stringValue = "\(Int(value.userLoad.rounded(toPlaces: 2) * 100)) %" self.idleField?.stringValue = "\(Int(value.idleLoad.rounded(toPlaces: 2) * 100)) %" diff --git a/Modules/Memory/popup.swift b/Modules/Memory/popup.swift index 1eaaf3f6..c9b383a9 100644 --- a/Modules/Memory/popup.swift +++ b/Modules/Memory/popup.swift @@ -101,7 +101,7 @@ internal class Popup: NSView { public func loadCallback(_ value: RAM_Usage) { DispatchQueue.main.async(execute: { - if self.window!.isVisible || !self.initialized { + if (self.window?.isVisible ?? false) || !self.initialized { self.activeField?.stringValue = Units(bytes: Int64(value.active!)).getReadableMemory() self.inactiveField?.stringValue = Units(bytes: Int64(value.inactive!)).getReadableMemory() self.wiredField?.stringValue = Units(bytes: Int64(value.wired!)).getReadableMemory() diff --git a/Modules/Net/popup.swift b/Modules/Net/popup.swift index 6e47689c..49bd086f 100644 --- a/Modules/Net/popup.swift +++ b/Modules/Net/popup.swift @@ -147,7 +147,7 @@ internal class Popup: NSView { public func usageCallback(_ value: Network_Usage) { DispatchQueue.main.async(execute: { - if !self.window!.isVisible && self.initialized && value.active { + if !(self.window?.isVisible ?? false) && self.initialized && value.active { return } @@ -179,7 +179,7 @@ internal class Popup: NSView { if value.connectionType != nil { var networkType = "" if value.connectionType == .wifi { - networkType = "\(value.networkName!) (WiFi)" + networkType = "\(value.networkName ?? "unknown") (WiFi)" } else if value.connectionType == .ethernet { networkType = "Ethernet" } diff --git a/Modules/Net/readers.swift b/Modules/Net/readers.swift index 3d38e0a8..dd21c650 100644 --- a/Modules/Net/readers.swift +++ b/Modules/Net/readers.swift @@ -179,12 +179,12 @@ internal class UsageReader: Reader { let matchingDict = matchingDictUM! as NSMutableDictionary matchingDict["IOPropertyMatch"] = [ "IOPrimaryInterface" : true] - + var matchingServices : io_iterator_t = 0 if IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &matchingServices) != KERN_SUCCESS { return nil } - + return matchingServices } @@ -203,11 +203,11 @@ internal class UsageReader: Reader { } IOObjectRelease(controllerService) } - + IOObjectRelease(intfService) intfService = IOIteratorNext(intfIterator) } - + return macAddress } } diff --git a/Stats.xcodeproj/project.pbxproj b/Stats.xcodeproj/project.pbxproj index ea98cf99..dbcedd0e 100644 --- a/Stats.xcodeproj/project.pbxproj +++ b/Stats.xcodeproj/project.pbxproj @@ -1680,7 +1680,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 2.1.1; + MARKETING_VERSION = 2.1.2; PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1712,7 +1712,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 2.1.1; + MARKETING_VERSION = 2.1.2; PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "";