fix: trying to fix the crash by fixing some data racing in the widgets (#1578)

This commit is contained in:
Serhiy Mytrovtsiy
2023-08-19 09:39:18 +02:00
parent c5a3657957
commit 5030d22ec5
15 changed files with 198 additions and 349 deletions

View File

@@ -1091,7 +1091,7 @@ private class ModeButtons: NSStackView {
if !Store.shared.bool(key: "Sensors_turnOffFanAlert", defaultValue: false) {
let alert = NSAlert()
alert.messageText = localizedString("Turn off fan")
alert.informativeText = localizedString("You are going to turn off the fan. That is not recommended action that can broke your mac, are you sure you want to do that?")
alert.informativeText = localizedString("You are going to turn off the fan. This is not recommended action that can damage your mac, are you sure you want to do that?")
alert.showsSuppressionButton = true
alert.addButton(withTitle: localizedString("Turn off"))
alert.addButton(withTitle: localizedString("Cancel"))

View File

@@ -49,16 +49,16 @@ public protocol Sensor_p {
var formattedPopupValue: String { get }
}
public struct Sensors_List: Codable {
public class Sensors_List: Codable {
private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.Sensors.SynchronizedArray", attributes: .concurrent)
private var list: [Sensor_p] = []
public var sensors: [Sensor_p] {
get {
self.queue.sync{self.list}
self.queue.sync{ self.list }
}
set(newValue) {
self.queue.sync {
set {
self.queue.async(flags: .barrier) {
self.list = newValue
}
}
@@ -76,7 +76,7 @@ public struct Sensors_List: Codable {
try container.encode(wrappers, forKey: .sensors)
}
public init(from decoder: Decoder) throws {
required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let wrappers = try container.decode([Sensor_w].self, forKey: .sensors)
self.sensors = wrappers.map { $0.sensor }