mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app/internal/window: (Windows) return all errors from NewContext
Instead of just returning the first error (from Direct3D), return the errors from all attempts. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -4,9 +4,11 @@ package window
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
@@ -359,18 +361,16 @@ func (w *window) NewContext() (Context, error) {
|
||||
sort.Slice(backends, func(i, j int) bool {
|
||||
return backends[i].priority < backends[j].priority
|
||||
})
|
||||
var cerr error
|
||||
var errs []string
|
||||
for _, b := range backends {
|
||||
ctx, err := b.initializer(w)
|
||||
if err == nil {
|
||||
return ctx, nil
|
||||
}
|
||||
if cerr == nil {
|
||||
cerr = err
|
||||
}
|
||||
errs = append(errs, err.Error())
|
||||
}
|
||||
if cerr != nil {
|
||||
return nil, cerr
|
||||
if len(errs) > 0 {
|
||||
return nil, fmt.Errorf("NewContext: failed to create a GPU device, tried: %s", strings.Join(errs, ", "))
|
||||
}
|
||||
return nil, errors.New("NewContext: no available backends")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user