Fix progress races (windows).

This commit is contained in:
Nuno Cruces 2021-07-12 18:13:08 +01:00
parent 15dc2768c4
commit b743781dc8

View file

@ -21,6 +21,8 @@ func progress(opts options) (ProgressDialog, error) {
} }
if opts.ctx == nil { if opts.ctx == nil {
opts.ctx = context.Background() opts.ctx = context.Background()
} else if cerr := opts.ctx.Err(); cerr != nil {
return nil, cerr
} }
dlg := &progressDialog{ dlg := &progressDialog{
@ -43,6 +45,7 @@ func progress(opts options) (ProgressDialog, error) {
} }
func progressDlg(opts options, dlg *progressDialog) (err error) { func progressDlg(opts options, dlg *progressDialog) (err error) {
defer dlg.init.Done()
defer setup()() defer setup()()
font := getFont() font := getFont()
defer font.Delete() defer font.Delete()
@ -170,6 +173,7 @@ func progressDlg(opts options, dlg *progressDialog) (err error) {
} else { } else {
sendMessage.Call(dlg.progCtl, 0x406 /* PBM_SETRANGE32 */, 0, uintptr(opts.maxValue)) sendMessage.Call(dlg.progCtl, 0x406 /* PBM_SETRANGE32 */, 0, uintptr(opts.maxValue))
} }
defer dlg.init.Add(1)
dlg.init.Done() dlg.init.Done()
if opts.ctx != nil { if opts.ctx != nil {