Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-01-07 09:38:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-01-07 09:47:17 +0300
commit11292edba6ec361cc7142c4e2d9af0289cd895bb (patch)
tree2ecee7643e19d3ae87157d4a4b6c07b2e397f170 /source/blender/editors/mesh
parent1ef59d0eb535c3d526a1a1f72e257b5aa5b15fb3 (diff)
BMesh: remove BMEditMesh.ob pointer
Remove this pointer since it's linking Mesh data back to the object, where a single edit-mesh may have multiple object users, causing incorrect assumptions in the code. Resolves dangling pointer part of the T72667 crash, although there are other issues which still need to be fixed. In EDBM_op_finish and EDBM_update_generic, full Main lookups have been added which should be replaced with mesh argument or the update tagging moved elsewhere.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c1
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c27
2 files changed, 20 insertions, 8 deletions
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index db7751af0f0..faa80341b0f 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -605,7 +605,6 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *
em->selectmode = um->selectmode;
bm->selectmode = um->selectmode;
- em->ob = ob;
bm->spacearr_dirty = BM_SPACEARR_DIRTY_ALL;
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 2cfb66b57f5..e3883ea04d4 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -41,6 +41,7 @@
#include "BKE_report.h"
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"
+#include "BKE_global.h"
#include "DEG_depsgraph.h"
@@ -166,8 +167,15 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool
BKE_editmesh_looptri_calc(em);
}
- if (em->ob) {
- DEG_id_tag_update(&((Mesh *)em->ob->data)->id, ID_RECALC_COPY_ON_WRITE);
+ {
+ /* FIXME: pass in mesh. */
+ Main *bmain = G_MAIN;
+ for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
+ if (mesh->edit_mesh == em) {
+ DEG_id_tag_update(&mesh->id, ID_RECALC_COPY_ON_WRITE);
+ break;
+ }
+ }
}
return false;
@@ -316,7 +324,6 @@ void EDBM_mesh_make(Object *ob, const int select_mode, const bool add_key_index)
me->edit_mesh->selectmode = me->edit_mesh->bm->selectmode = select_mode;
me->edit_mesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0;
- me->edit_mesh->ob = ob;
/* we need to flush selection because the mode may have changed from when last in editmode */
EDBM_selectmode_flush(me->edit_mesh);
@@ -1416,10 +1423,16 @@ void EDBM_stats_update(BMEditMesh *em)
*/
void EDBM_update_generic(BMEditMesh *em, const bool do_tessellation, const bool is_destructive)
{
- Object *ob = em->ob;
- /* order of calling isn't important */
- DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY);
- WM_main_add_notifier(NC_GEOM | ND_DATA, ob->data);
+ /* FIXME: pass in mesh. */
+ Main *bmain = G_MAIN;
+ for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
+ if (mesh->edit_mesh == em) {
+ /* Order of calling isn't important. */
+ DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
+ WM_main_add_notifier(NC_GEOM | ND_DATA, &mesh->id);
+ break;
+ }
+ }
if (do_tessellation) {
BKE_editmesh_looptri_calc(em);