Object Mode: Loop over objects for ED_editors_exit

We could loop over active objects but this ensures don't miss any
and avoids complicated context checks.
This commit is contained in:
Campbell Barton 2018-02-13 21:00:26 +11:00
parent c8597a465f
commit 8234f24838
1 changed files with 15 additions and 18 deletions

View File

@ -35,6 +35,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
@ -109,7 +110,6 @@ void ED_editors_init(bContext *C)
void ED_editors_exit(bContext *C)
{
Main *bmain = CTX_data_main(C);
Scene *sce;
if (!bmain)
return;
@ -117,23 +117,20 @@ void ED_editors_exit(bContext *C)
/* frees all editmode undos */
undo_editmode_clear();
ED_undo_paint_free();
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->obedit) {
Object *ob = sce->obedit;
if (ob) {
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
if (me->edit_btmesh) {
EDBM_mesh_free(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
me->edit_btmesh = NULL;
}
}
else if (ob->type == OB_ARMATURE) {
ED_armature_edit_free(ob->data);
}
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
if (me->edit_btmesh) {
EDBM_mesh_free(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
me->edit_btmesh = NULL;
}
}
else if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
if (arm->edbo) {
ED_armature_edit_free(ob->data);
}
}
}