Fix crash dragging images into the animation player

Resolve issues with the animation player drag & drop.

- IMB_exit ran before attempting to load the dropped image,
  crashing when the image was loaded.
- The old event consumer wasn't removed from the system
  causing events to be processed that accessed freed stack memory.
This commit is contained in:
Campbell Barton
2023-10-13 17:35:36 +11:00
parent ac82a7c3f8
commit 91c5eca81f

View File

@@ -1778,8 +1778,9 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
exit(EXIT_FAILURE);
}
GHOST_EventConsumerHandle ghost_event_consumer = nullptr;
{
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps);
ghost_event_consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps);
GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace);
@@ -1792,7 +1793,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
exit(EXIT_FAILURE);
}
GHOST_AddEventConsumer(ps.ghost_data.system, consumer);
GHOST_AddEventConsumer(ps.ghost_data.system, ghost_event_consumer);
ps.ghost_data.window = playanim_window_open(
ps.ghost_data.system, "Blender Animation Player", start_x, start_y, ibuf->x, ibuf->y);
@@ -2055,7 +2056,6 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
/* we still miss freeing a lot!,
* but many areas could skip initialization too for anim play */
IMB_exit();
DEG_free_node_types();
BLF_exit();
@@ -2066,6 +2066,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GPU_context_discard(ps.ghost_data.gpu_context);
ps.ghost_data.gpu_context = nullptr;
}
GHOST_RemoveEventConsumer(ps.ghost_data.system, ghost_event_consumer);
GHOST_DisposeEventConsumer(ghost_event_consumer);
GHOST_DisposeWindow(ps.ghost_data.system, ps.ghost_data.window);
@@ -2075,6 +2077,10 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
return filepath;
}
GHOST_DisposeSystem(ps.ghost_data.system);
IMB_exit();
totblock = MEM_get_memory_blocks_in_use();
if (totblock != 0) {
/* prints many bAKey, bArgument's which are tricky to fix */