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
|
||||
isDownloadComplete bool
|
||||
downloadFailed bool
|
||||
downloadDone bool
|
||||
}
|
||||
|
||||
// Init performs basic page initialization and creation of static assets.
|
||||
@@ -178,7 +179,10 @@ func (p *Home) Update(dt float32) error {
|
||||
} else {
|
||||
p.setMessage("Status: READY", colors.Green)
|
||||
p.isDownloadComplete = true
|
||||
close(p.Context.DownloadDone)
|
||||
if !p.downloadDone {
|
||||
p.downloadDone = true
|
||||
close(p.Context.DownloadDone)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user