win-capture: Clear stale pointers for game capture

Fixes shmem crashes when using Alt+Tab.
This commit is contained in:
jpark37 2021-08-27 21:15:58 -07:00 committed by Jim
parent 3e4c275efc
commit c5e7a6f23b

View File

@ -336,12 +336,12 @@ static void stop_capture(struct game_capture *gc)
obs_enter_graphics();
gs_texrender_destroy(gc->extra_texrender);
gs_texture_destroy(gc->extra_texture);
gs_texture_destroy(gc->texture);
obs_leave_graphics();
gc->extra_texrender = NULL;
gs_texture_destroy(gc->extra_texture);
gc->extra_texture = NULL;
gs_texture_destroy(gc->texture);
gc->texture = NULL;
obs_leave_graphics();
if (gc->active)
info("capture stopped");
@ -1563,8 +1563,11 @@ static inline bool init_shmem_capture(struct game_capture *gc)
obs_enter_graphics();
gs_texrender_destroy(gc->extra_texrender);
gc->extra_texrender = NULL;
gs_texture_destroy(gc->extra_texture);
gc->extra_texture = NULL;
gs_texture_destroy(gc->texture);
gc->texture = NULL;
gs_texture_t *const texture =
gs_texture_create(gc->cx, gc->cy, format, 1, NULL, GS_DYNAMIC);
obs_leave_graphics();
@ -1608,8 +1611,11 @@ static inline bool init_shtex_capture(struct game_capture *gc)
{
obs_enter_graphics();
gs_texrender_destroy(gc->extra_texrender);
gc->extra_texrender = NULL;
gs_texture_destroy(gc->extra_texture);
gc->extra_texture = NULL;
gs_texture_destroy(gc->texture);
gc->texture = NULL;
gs_texture_t *const texture =
gs_texture_open_shared(gc->shtex_data->tex_handle);
bool success = texture != NULL;