Join operator with override crashes Blender 2.79 #52982

Closed
opened 2017-10-03 12:55:35 +02:00 by notallowed · 7 comments

System Information
Linux Mint 18.2, GTX 660 Ti

Blender Version
Broken: 2.79.5bd8ac9abfa
Worked: 2.78c.e92f2352830

Short description of error
When setting active object trough context override on "bpy.ops.object.join" operator, blender crashes.

Exact steps for others to reproduce the error

  1. Open attached blend file: untitled.blend
  2. Press execute the script (Alt+P in text editor)
  3. Crash!
**System Information** Linux Mint 18.2, GTX 660 Ti **Blender Version** Broken: 2.79.5bd8ac9abfa Worked: 2.78c.e92f2352830 **Short description of error** When setting active object trough context override on "bpy.ops.object.join" operator, blender crashes. **Exact steps for others to reproduce the error** 1. Open attached blend file: [untitled.blend](https://archive.blender.org/developer/F934611/untitled.blend) 2. Press execute the script (Alt+P in text editor) 3. Crash!
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @simon_lusenc

Added subscriber: @simon_lusenc

Added subscribers: @mont29, @Sergey

Added subscribers: @mont29, @Sergey
Bastien Montagne was assigned by Sergey Sharybin 2017-10-03 15:56:59 +02:00

@mont29, comes from 9f67367. I'm not sure why we need a base for join, all the logic uses base->object anyway. Here is a proposed fix:

P534: Fix #52982

diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index ba57cda6916..c900373a59c 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -78,7 +78,7 @@
 
 static void join_mesh_single(
         Main *bmain, Scene *scene,
-        Object *ob_dst, Base *base_src, float imat- [x][4],
+        Object *ob_dst, Object *ob_src, float imat- [x][4],
         MVert **mvert_pp, MEdge **medge_pp, MLoop **mloop_pp, MPoly **mpoly_pp,
         CustomData *vdata, CustomData *edata, CustomData *ldata, CustomData *pdata,
         int totvert, int totedge, int totloop, int totpoly,
@@ -88,7 +88,7 @@ static void join_mesh_single(
 {
 	int a, b;
 
-	Mesh *me = base_src->object->data;
+	Mesh *me = ob_src->data;
 	MVert *mvert = *mvert_pp;
 	MEdge *medge = *medge_pp;
 	MLoop *mloop = *mloop_pp;
@@ -112,10 +112,10 @@ static void join_mesh_single(
 
 			/* Build src to merged mapping of vgroup indices. */
 			bDeformGroup *dg_src;
-			int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&base_src->object->defbase));
+			int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&ob_src->defbase));
 			bool is_vgroup_remap_needed = false;
 
-			for (dg_src = base_src->object->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) {
+			for (dg_src = ob_src->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) {
 				vgroup_index_map- [x] = defgroup_name_index(ob_dst, dg_src->name);
 				is_vgroup_remap_needed = is_vgroup_remap_needed || (vgroup_index_map- [x] != b);
 			}
@@ -130,11 +130,11 @@ static void join_mesh_single(
 		}
 
 		/* if this is the object we're merging into, no need to do anything */
-		if (base_src->object != ob_dst) {
+		if (ob_src != ob_dst) {
 			float cmat- [x][4];
 
 			/* watch this: switch matmul order really goes wrong */
-			mul_m4_m4m4(cmat, imat, base_src->object->obmat);
+			mul_m4_m4m4(cmat, imat, ob_src->obmat);
 
 			/* transform vertex coordinates into new space */
 			for (a = 0, mvert = *mvert_pp; a < me->totvert; a++, mvert++) {
@@ -211,13 +211,13 @@ static void join_mesh_single(
 	}
 
 	if (me->totloop) {
-		if (base_src->object != ob_dst) {
+		if (ob_src != ob_dst) {
 			MultiresModifierData *mmd;
 
-			multiresModifier_prepare_join(scene, base_src->object, ob_dst);
+			multiresModifier_prepare_join(scene, ob_src, ob_dst);
 
-			if ((mmd = get_multires_modifier(scene, base_src->object, true))) {
-				ED_object_iter_other(bmain, base_src->object, true,
+			if ((mmd = get_multires_modifier(scene, ob_src, true))) {
+				ED_object_iter_other(bmain, ob_src, true,
 				                     ED_object_multires_update_totlevels_cb,
 				                     &mmd->totlvl);
 			}
@@ -235,8 +235,8 @@ static void join_mesh_single(
 	if (me->totpoly) {
 		if (matmap) {
 			/* make mapping for materials */
-			for (a = 1; a <= base_src->object->totcol; a++) {
-				Material *ma = give_current_material(base_src->object, a);
+			for (a = 1; a <= ob_src->totcol; a++) {
+				Material *ma = give_current_material(ob_src, a);
 
 				for (b = 0; b < totcol; b++) {
 					if (ma == matar[b]) {
@@ -271,8 +271,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
-	Base *ob_base = CTX_data_active_base(C);
-	Object *ob = ob_base->object;
+	Object *ob = CTX_data_active_object(C);
 	Material **matar = NULL, *ma;
 	Mesh *me;
 	MVert *mvert = NULL;
@@ -495,7 +494,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
 	 */
 	join_mesh_single(
 	            bmain, scene,
-	            ob, ob_base, imat,
+	            ob, ob, imat,
 	            &mvert, &medge, &mloop, &mpoly,
 	            &vdata, &edata, &ldata, &pdata,
 	            totvert, totedge, totloop, totpoly,
@@ -512,7 +511,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
 		if (base->object->type == OB_MESH) {
 			join_mesh_single(
 			            bmain, scene,
-			            ob, base, imat,
+			            ob, base->object, imat,
 			            &mvert, &medge, &mloop, &mpoly,
 			            &vdata, &edata, &ldata, &pdata,
 			            totvert, totedge, totloop, totpoly,

@mont29, comes from 9f67367. I'm not sure why we need a base for join, all the logic uses `base->object` anyway. Here is a proposed fix: [P534: Fix #52982](https://archive.blender.org/developer/P534.txt) ``` diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index ba57cda6916..c900373a59c 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -78,7 +78,7 @@ static void join_mesh_single( Main *bmain, Scene *scene, - Object *ob_dst, Base *base_src, float imat- [x][4], + Object *ob_dst, Object *ob_src, float imat- [x][4], MVert **mvert_pp, MEdge **medge_pp, MLoop **mloop_pp, MPoly **mpoly_pp, CustomData *vdata, CustomData *edata, CustomData *ldata, CustomData *pdata, int totvert, int totedge, int totloop, int totpoly, @@ -88,7 +88,7 @@ static void join_mesh_single( { int a, b; - Mesh *me = base_src->object->data; + Mesh *me = ob_src->data; MVert *mvert = *mvert_pp; MEdge *medge = *medge_pp; MLoop *mloop = *mloop_pp; @@ -112,10 +112,10 @@ static void join_mesh_single( /* Build src to merged mapping of vgroup indices. */ bDeformGroup *dg_src; - int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&base_src->object->defbase)); + int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&ob_src->defbase)); bool is_vgroup_remap_needed = false; - for (dg_src = base_src->object->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) { + for (dg_src = ob_src->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) { vgroup_index_map- [x] = defgroup_name_index(ob_dst, dg_src->name); is_vgroup_remap_needed = is_vgroup_remap_needed || (vgroup_index_map- [x] != b); } @@ -130,11 +130,11 @@ static void join_mesh_single( } /* if this is the object we're merging into, no need to do anything */ - if (base_src->object != ob_dst) { + if (ob_src != ob_dst) { float cmat- [x][4]; /* watch this: switch matmul order really goes wrong */ - mul_m4_m4m4(cmat, imat, base_src->object->obmat); + mul_m4_m4m4(cmat, imat, ob_src->obmat); /* transform vertex coordinates into new space */ for (a = 0, mvert = *mvert_pp; a < me->totvert; a++, mvert++) { @@ -211,13 +211,13 @@ static void join_mesh_single( } if (me->totloop) { - if (base_src->object != ob_dst) { + if (ob_src != ob_dst) { MultiresModifierData *mmd; - multiresModifier_prepare_join(scene, base_src->object, ob_dst); + multiresModifier_prepare_join(scene, ob_src, ob_dst); - if ((mmd = get_multires_modifier(scene, base_src->object, true))) { - ED_object_iter_other(bmain, base_src->object, true, + if ((mmd = get_multires_modifier(scene, ob_src, true))) { + ED_object_iter_other(bmain, ob_src, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); } @@ -235,8 +235,8 @@ static void join_mesh_single( if (me->totpoly) { if (matmap) { /* make mapping for materials */ - for (a = 1; a <= base_src->object->totcol; a++) { - Material *ma = give_current_material(base_src->object, a); + for (a = 1; a <= ob_src->totcol; a++) { + Material *ma = give_current_material(ob_src, a); for (b = 0; b < totcol; b++) { if (ma == matar[b]) { @@ -271,8 +271,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Base *ob_base = CTX_data_active_base(C); - Object *ob = ob_base->object; + Object *ob = CTX_data_active_object(C); Material **matar = NULL, *ma; Mesh *me; MVert *mvert = NULL; @@ -495,7 +494,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) */ join_mesh_single( bmain, scene, - ob, ob_base, imat, + ob, ob, imat, &mvert, &medge, &mloop, &mpoly, &vdata, &edata, &ldata, &pdata, totvert, totedge, totloop, totpoly, @@ -512,7 +511,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) if (base->object->type == OB_MESH) { join_mesh_single( bmain, scene, - ob, base, imat, + ob, base->object, imat, &mvert, &medge, &mloop, &mpoly, &vdata, &edata, &ldata, &pdata, totvert, totedge, totloop, totpoly, ```

@Sergey indeed, cannot see any reason to pass base if we only use object, your fix lgtm.

@Sergey indeed, cannot see any reason to pass base if we only use object, your fix lgtm.

This issue was referenced by b22b2c783d

This issue was referenced by b22b2c783daa22198b1268b0e4045c76877b5a35

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#52982
No description provided.