mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/ui: bug fix: ignore ERROR_BUSY when deleting a GL context
Closes #2518
This commit is contained in:
parent
7018318546
commit
471237b701
@ -6,10 +6,13 @@
|
|||||||
package glfwwin
|
package glfwwin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -321,7 +324,10 @@ func getProcAddressWGL(procname string) uintptr {
|
|||||||
|
|
||||||
func destroyContextWGL(window *Window) error {
|
func destroyContextWGL(window *Window) error {
|
||||||
if window.context.wgl.handle != 0 {
|
if window.context.wgl.handle != 0 {
|
||||||
if err := wglDeleteContext(window.context.wgl.handle); err != nil {
|
// Ignore ERROR_BUSY. This happens when the thread is different from the context thread (#2518).
|
||||||
|
// This is a known issue of GLFW (glfw/glfw#2239).
|
||||||
|
// TODO: Delete the context on an appropriate thread.
|
||||||
|
if err := wglDeleteContext(window.context.wgl.handle); err != nil && !errors.Is(err, windows.ERROR_BUSY) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
window.context.wgl.handle = 0
|
window.context.wgl.handle = 0
|
||||||
|
@ -1004,8 +1004,7 @@ func (u *userInterfaceImpl) update() (float64, float64, error) {
|
|||||||
|
|
||||||
func (u *userInterfaceImpl) loopGame() error {
|
func (u *userInterfaceImpl) loopGame() error {
|
||||||
defer u.mainThread.Call(func() {
|
defer u.mainThread.Call(func() {
|
||||||
// An explicit destorying a window tries to delete a GL context on the main thread on Windows (wglDeleteContext),
|
u.window.Destroy()
|
||||||
// but this causes an error unfortunately.
|
|
||||||
glfw.Terminate()
|
glfw.Terminate()
|
||||||
})
|
})
|
||||||
for {
|
for {
|
||||||
|
Loading…
Reference in New Issue
Block a user