[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60227] trunk/blender/source/blender/ editors/object/object_transform.c: fix [#36771] Prevent 'Apply Transform' for Objects with a linked mesh

Campbell Barton ideasman42 at gmail.com
Thu Sep 19 00:45:14 CEST 2013


Revision: 60227
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60227
Author:   campbellbarton
Date:     2013-09-18 22:45:14 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
fix [#36771] Prevent 'Apply Transform' for Objects with a linked mesh

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_transform.c

Modified: trunk/blender/source/blender/editors/object/object_transform.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_transform.c	2013-09-18 22:21:32 UTC (rev 60226)
+++ trunk/blender/source/blender/editors/object/object_transform.c	2013-09-18 22:45:14 UTC (rev 60227)
@@ -50,6 +50,7 @@
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
 #include "BKE_main.h"
+#include "BKE_idcode.h"
 #include "BKE_mball.h"
 #include "BKE_mesh.h"
 #include "BKE_object.h"
@@ -379,54 +380,45 @@
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
-	int change = 1;
+	bool change = true;
 	
 	/* first check if we can execute */
 	CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
 	{
+		if (ELEM6(ob->type, OB_MESH, OB_ARMATURE, OB_LATTICE, OB_MBALL, OB_CURVE, OB_SURF)) {
+			ID *obdata = ob->data;
+			if (ID_REAL_USERS(obdata) > 1) {
+				BKE_reportf(reports, RPT_ERROR,
+				            "Cannot apply to a multi user: Object \"%s\", %s \"%s\", aborting",
+				            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+				change = false;
+			}
 
-		if (ob->type == OB_MESH) {
-			if (ID_REAL_USERS(ob->data) > 1) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user mesh, doing nothing");
-				change = 0;
+			if (obdata->lib) {
+				BKE_reportf(reports, RPT_ERROR,
+				            "Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
+				            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+				change = false;
 			}
 		}
-		else if (ob->type == OB_ARMATURE) {
-			if (ID_REAL_USERS(ob->data) > 1) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user armature, doing nothing");
-				change = 0;
-			}
-		}
-		else if (ob->type == OB_LATTICE) {
-			if (ID_REAL_USERS(ob->data) > 1) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user lattice, doing nothing");
-				change = 0;
-			}
-		}
-		else if (ob->type == OB_MBALL) {
-			if (ID_REAL_USERS(ob->data) > 1) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user metaball, doing nothing");
-				change = 0;
-			}
-		}
-		else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+
+		if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+			ID *obdata = ob->data;
 			Curve *cu;
 
-			if (ID_REAL_USERS(ob->data) > 1) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing");
-				change = 0;
-			}
-
 			cu = ob->data;
 
 			if (((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) && (apply_rot || apply_loc)) {
-				BKE_report(reports, RPT_ERROR,
-				           "Neither rotation nor location could be applied to a 2D curve, doing nothing");
-				change = 0;
+				BKE_reportf(reports, RPT_ERROR,
+				            "Rotation/Location can't apply to a 2D curve: Object \"%s\", %s \"%s\", aborting",
+				            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+				change = false;
 			}
 			if (cu->key) {
-				BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing");
-				change = 0;
+				BKE_reportf(reports, RPT_ERROR,
+				            "Can't apply to a curve with shape-keys: Object \"%s\", %s \"%s\", aborting",
+				            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+				change = false;
 			}
 		}
 	}
@@ -435,7 +427,7 @@
 	if (!change)
 		return OPERATOR_CANCELLED;
 
-	change = 0;
+	change = false;
 
 	/* now execute */
 	CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -600,7 +592,7 @@
 
 		DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
 
-		change = 1;
+		change = true;
 	}
 	CTX_DATA_END;
 




More information about the Bf-blender-cvs mailing list