BKE: Changing ID freeing order.

Screen can contains manipulators that contains batches to be freed before the opengl contexts (in WM) are destroyed.

Also fix other GPU related free.
This commit is contained in:
Clément Foucault 2018-02-21 22:51:35 +01:00
parent 7be1928ea1
commit 87c72a7d27
Notes: blender-bot 2023-02-14 06:10:09 +01:00
Referenced by commit 648df0fcdb, Revert "BKE: Changing ID freeing order."
Referenced by issue #54121, Crash on loading saved file (invalid view layer)
3 changed files with 15 additions and 15 deletions

View File

@ -1067,6 +1067,8 @@ int set_listbasepointers(Main *main, ListBase **lb)
* This is important because freeing data decreases usercounts of other datablocks,
* if this data is its self freed it can crash. */
lb[INDEX_ID_LI] = &(main->library); /* Libraries may be accessed from pretty much any other ID... */
lb[INDEX_ID_WS] = &(main->workspaces); /* before wm, so it's freed after it! */
lb[INDEX_ID_WM] = &(main->wm);
lb[INDEX_ID_IP] = &(main->ipo);
lb[INDEX_ID_AC] = &(main->action); /* moved here to avoid problems when freeing with animato (aligorith) */
lb[INDEX_ID_KE] = &(main->key);
@ -1108,8 +1110,6 @@ int set_listbasepointers(Main *main, ListBase **lb)
lb[INDEX_ID_OB] = &(main->object);
lb[INDEX_ID_LS] = &(main->linestyle); /* referenced by scenes */
lb[INDEX_ID_SCE] = &(main->scene);
lb[INDEX_ID_WS] = &(main->workspaces); /* before wm, so it's freed after it! */
lb[INDEX_ID_WM] = &(main->wm);
lb[INDEX_ID_MSK] = &(main->mask);
lb[INDEX_ID_NULL] = NULL;

View File

@ -519,6 +519,8 @@ enum {
* keep them in sync! */
enum {
INDEX_ID_LI = 0,
INDEX_ID_WS,
INDEX_ID_WM,
INDEX_ID_IP,
INDEX_ID_AC,
INDEX_ID_KE,
@ -551,8 +553,6 @@ enum {
INDEX_ID_OB,
INDEX_ID_LS,
INDEX_ID_SCE,
INDEX_ID_WS,
INDEX_ID_WM,
INDEX_ID_MSK,
INDEX_ID_NULL,
};

View File

@ -521,6 +521,17 @@ void WM_exit_ext(bContext *C, const bool do_python)
COM_deinitialize();
#endif
if (!G.background) {
#ifdef WITH_OPENSUBDIV
BKE_subsurf_osd_cleanup();
#endif
GPU_global_buffer_pool_free();
GPU_free_unused_buffers();
GPU_exit();
}
BKE_blender_free(); /* blender.c, does entire library and spacetypes */
// free_matcopybuf();
ANIM_fcurves_copybuf_free();
@ -565,17 +576,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
(void)do_python;
#endif
if (!G.background) {
#ifdef WITH_OPENSUBDIV
BKE_subsurf_osd_cleanup();
#endif
GPU_global_buffer_pool_free();
GPU_free_unused_buffers();
GPU_exit();
}
BKE_undo_reset();
ED_file_exit(); /* for fsmenu */