Skip to content

Commit a246c95

Browse files
committed
fixed race condition in lazy log copy
fixed controller list for controller window
1 parent 8526e78 commit a246c95

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

gui/sdlimgui/lazyvalues/log.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,16 @@ func newLazyLog(val *Lazy) *LazyLog {
3737
}
3838

3939
func (lz *LazyLog) update() {
40-
lz.val.Dbg.PushRawEvent(func() {
40+
// when making a copy of the log we only want to do it if the log has been
41+
// dirtied. to do this we need to note the timestamp of the most recent log
42+
// entry so we can pass it to the logger.Copy() function
43+
timestamp := time.Unix(0, 0)
44+
if len(lz.Log) > 0 {
45+
timestamp = lz.Log[len(lz.Log)-1].Timestamp
46+
}
4147

42-
// make a copy of the log. the logger.Copy() function requires a
43-
// timestamp of the most recent log entry. the Copy() function uses
44-
// this to decide whether a new copy is required. if the Copy()
45-
// function return nil then we'll just coninue to use the old copy
46-
var ref time.Time
47-
if len(lz.Log) > 0 {
48-
ref = lz.Log[len(lz.Log)-1].Timestamp
49-
} else {
50-
ref = time.Unix(0, 0)
51-
}
52-
if l := logger.Copy(ref); l != nil {
48+
lz.val.Dbg.PushRawEvent(func() {
49+
if l := logger.Copy(timestamp); l != nil {
5350
lz.atomicLog.Store(l)
5451
lz.atomicDirty.Store(true)
5552
} else {

hardware/riot/ports/controllers/controllers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ package controllers
1818
// ControllerList is the list of controllers. These are the values that can be
1919
// returned by the ID() function of the ports.Peripheral implementations in
2020
// this package
21-
var ControllerList = []string{"Auto", "Stick", "Paddle", "Keyboard"}
21+
var ControllerList = []string{"Stick", "Paddle", "Keyboard"}

0 commit comments

Comments
 (0)