mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: trying to fix the crash by fixing some data racing in the widgets (#1578)
This commit is contained in:
@@ -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"))
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user