Fixed iOS build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 2a90c15..ba31b6e 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -1597,14 +1597,17 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
if (!(window_flags & SDL_WINDOW_METAL)) {
changed_window = SDL_TRUE;
if (SDL_RecreateWindow(window, (window_flags & ~SDL_WINDOW_OPENGL) | SDL_WINDOW_METAL) < 0) {
- goto error;
+ return NULL;
}
}
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
if (!renderer) {
SDL_OutOfMemory();
- goto error;
+ if (changed_window) {
+ SDL_RecreateWindow(window, window_flags);
+ }
+ return NULL;
}
// !!! FIXME: MTLCopyAllDevices() can find other GPUs on macOS...
@@ -1613,7 +1616,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
if (mtldevice == nil) {
SDL_free(renderer);
SDL_SetError("Failed to obtain Metal device");
- goto error;
+ if (changed_window) {
+ SDL_RecreateWindow(window, window_flags);
+ }
+ return NULL;
}
view = SDL_Metal_CreateView(window);
@@ -1623,7 +1629,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
[mtldevice release];
#endif
SDL_free(renderer);
- goto error;
+ if (changed_window) {
+ SDL_RecreateWindow(window, window_flags);
+ }
+ return NULL;
}
// !!! FIXME: error checking on all of this.
@@ -1635,7 +1644,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
#endif
SDL_Metal_DestroyView(view);
SDL_free(renderer);
- goto error;
+ if (changed_window) {
+ SDL_RecreateWindow(window, window_flags);
+ }
+ return NULL;
}
renderer->driverdata = (void*)CFBridgingRetain(data);
@@ -1874,13 +1886,6 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
#endif
return renderer;
-
-error:
- if (changed_window) {
- /* Uh oh, better try to put it back... */
- SDL_RecreateWindow(window, window_flags);
- }
- return NULL;
}}
SDL_RenderDriver METAL_RenderDriver = {