Retry hardware cursor creation.
On Windows, a spurious error sometimes occur when creating cursors. We retry a few times before before having to give up and fall back to software cursors.
This commit is contained in:
@@ -144,6 +144,8 @@ namespace OpenRA.Renderer.Sdl2
|
||||
var sur = (SDL2.SDL.SDL_Surface)Marshal.PtrToStructure(surface, typeof(SDL2.SDL.SDL_Surface));
|
||||
Marshal.Copy(data, 0, sur.pixels, data.Length);
|
||||
|
||||
// This call very occasionally fails on Windows, but often works when retried.
|
||||
for (var retries = 0; retries < 3 && Cursor == IntPtr.Zero; retries++)
|
||||
Cursor = SDL.SDL_CreateColorCursor(surface, hotspot.X, hotspot.Y);
|
||||
if (Cursor == IntPtr.Zero)
|
||||
throw new InvalidDataException("Failed to create cursor: {0}".F(SDL.SDL_GetError()));
|
||||
|
||||
Reference in New Issue
Block a user