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

@@ -162,10 +162,7 @@ open class Module: Module_p {
// load function which call when app start
public func mount() {
guard self.enabled else {
return
}
guard self.enabled else { return }
self.readers.forEach { (reader: Reader_p) in
reader.initStoreValues(title: self.config.name)
reader.start()

View File

@@ -158,15 +158,15 @@ open class WidgetWrapper: NSView, widget_p {
public var type: widget_t
public var title: String
public var position: Int = -1
public var widthHandler: (() -> Void)? = nil
public var shadowSize: CGSize
internal var queue: DispatchQueue
public init(_ type: widget_t, title: String, frame: NSRect) {
self.type = type
self.title = title
self.shadowSize = frame.size
self.queue = DispatchQueue(label: "eu.exelban.Stats.WidgetWrapper.\(type.rawValue).\(title)")
super.init(frame: frame)
}
@@ -372,6 +372,7 @@ public class MenuBar {
private var moduleName: String
private var menuBarItem: NSStatusItem? = nil
private var active: Bool = false
private var queue: DispatchQueue
private var combinedModules: Bool {
Store.shared.bool(key: "CombinedModules", defaultValue: false)
@@ -394,6 +395,7 @@ public class MenuBar {
init(moduleName: String) {
self.moduleName = moduleName
self.queue = DispatchQueue(label: "eu.exelban.Stats.MenuBar.\(moduleName)")
self.oneView = Store.shared.bool(key: "\(self.moduleName)_oneView", defaultValue: self.oneView)
self.view.identifier = NSUserInterfaceItemIdentifier(rawValue: moduleName)