mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55: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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
@@ -359,18 +361,16 @@ func (w *window) NewContext() (Context, error) {
|
|||||||
sort.Slice(backends, func(i, j int) bool {
|
sort.Slice(backends, func(i, j int) bool {
|
||||||
return backends[i].priority < backends[j].priority
|
return backends[i].priority < backends[j].priority
|
||||||
})
|
})
|
||||||
var cerr error
|
var errs []string
|
||||||
for _, b := range backends {
|
for _, b := range backends {
|
||||||
ctx, err := b.initializer(w)
|
ctx, err := b.initializer(w)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
}
|
}
|
||||||
if cerr == nil {
|
errs = append(errs, err.Error())
|
||||||
cerr = err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if cerr != nil {
|
if len(errs) > 0 {
|
||||||
return nil, cerr
|
return nil, fmt.Errorf("NewContext: failed to create a GPU device, tried: %s", strings.Join(errs, ", "))
|
||||||
}
|
}
|
||||||
return nil, errors.New("NewContext: no available backends")
|
return nil, errors.New("NewContext: no available backends")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user