Fix double-close panic on DownloadDone channel
When transitioning from DOWNLOADING_ASSETS to READY, checkState() re-navigates to HOME. The new Home page sees the already-closed MessageChannel and tries to close DownloadDone again, causing a panic that restarts the process. Guard the close with a downloadDone bool field on Home.
This commit is contained in:
@@ -32,6 +32,7 @@ type Home struct {
|
|||||||
baseFontSize int
|
baseFontSize int
|
||||||
isDownloadComplete bool
|
isDownloadComplete bool
|
||||||
downloadFailed bool
|
downloadFailed bool
|
||||||
|
downloadDone bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init performs basic page initialization and creation of static assets.
|
// Init performs basic page initialization and creation of static assets.
|
||||||
@@ -178,8 +179,11 @@ func (p *Home) Update(dt float32) error {
|
|||||||
} else {
|
} else {
|
||||||
p.setMessage("Status: READY", colors.Green)
|
p.setMessage("Status: READY", colors.Green)
|
||||||
p.isDownloadComplete = true
|
p.isDownloadComplete = true
|
||||||
|
if !p.downloadDone {
|
||||||
|
p.downloadDone = true
|
||||||
close(p.Context.DownloadDone)
|
close(p.Context.DownloadDone)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user