veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.2k stars 218 forks source link

renderer becomes invalid #359

Closed Pixdigit closed 5 years ago

Pixdigit commented 5 years ago

Are there any operations that cause a renderer to become invalid? Because I have a test that succeeds when run in isolation but fails when run together with the other tests. Since almost all tests involve the renderer I cannot isolate a test that causes the renderer to become invalid. If you want to check out the error run the code here and apply this patch. The failing test is TestZSpace

veeableful commented 5 years ago

Hi @Pixdigit, I couldn't find a test called TestZSpace. I checked out the sprite-refactor branch and applied the patch but I couldn't find any function matching that name.

Pixdigit commented 5 years ago

Ok, my bad. I didnt know git diff --patch didnt actually patch in new files. Then just create a file zSpace_test.go with this in it.

Pixdigit commented 5 years ago

Please for now ignore all the comments as I am currently working on a refactor so I wanted to have the smallest broken code. Also since the code was copied from NewEmptyFame() so the error messages arent too accurate for TestZSpace()

veeableful commented 5 years ago

Hi @Pixdigit, sorry but what was the error that you encountered? It seems like the test passed for me.

Pixdigit commented 5 years ago

The exact error is: zSpace_test.go:14: could not copy pixel buffer into frame: Invalid renderer Which is returned after a call to screenRenderer.CreateTexture The test fails with --short but passes with --short --run="TestZSpace"

Pixdigit commented 5 years ago

After hours of searching through the code I found the error. Dont ask why since I dont know myself. But in one test I called sdl.Quit() for some reason. Of course that would lead to an invalid renderer. Still wonder why I did that and why I didnt notice that much sooner. Thank you for your time.