Skip to content

Commit 2c13c87

Browse files
committed
Fix disappearing textures when building with -O2
Cause: out-of-scope pointer in base_gauge_blit_texture
1 parent 8ff1e1b commit 2c13c87

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Diff for: base-gauge.c

+15-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "SDL_rect.h"
1414
#include "base-gauge.h"
15+
#include "misc.h"
1516
#include "sdl-colors.h"
1617
#include "view.h"
1718

@@ -232,22 +233,25 @@ int base_gauge_blit_texture(BaseGauge *self, RenderContext *ctx,
232233
// printf("After clipping: ");
233234
// SDLExt_RectDump(&fdst);
234235
#endif
235-
GPU_Rect *dst_rectf, *src_rectf;
236236
float x,y;
237237

238-
dst_rectf = &rectf(&fdst);
239-
240238
if(!srcrect){
241-
x = src->w/2.0 + dst_rectf->x;
242-
y = src->h/2.0 + dst_rectf->y;
243-
src_rectf = NULL;
239+
x = src->w/2.0 + fdst.x;
240+
y = src->h/2.0 + fdst.y;
244241
}else{
245-
x = srcrect->w/2.0 + dst_rectf->x;
246-
y = srcrect->h/2.0 + dst_rectf->y;
247-
src_rectf = &rectf(srcrect);
242+
x = srcrect->w/2.0 + fdst.x;
243+
y = srcrect->h/2.0 + fdst.y;
248244
}
249-
250-
GPU_Blit(src, src_rectf, ctx->target.target, x, y);
245+
#if 0
246+
printf(
247+
"GPU_Blit from %p {.x:%0.2f, .y:%0.2f, .w:%0.2f, .h:%0.2f} to %p x:%0.2f y:%0.2f\n",
248+
src,
249+
src_rectf->x,src_rectf->y,
250+
src_rectf->w,src_rectf->h,
251+
ctx->target.target, x, y
252+
);
253+
#endif
254+
GPU_Blit(src, srcrect ? &rectf(srcrect) : NULL, ctx->target.target, x, y);
251255
return 0;
252256
}
253257

0 commit comments

Comments
 (0)