[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28703] trunk/blender/source/blender/ editors/mesh/mesh_data.c: Fixed a crash when dropping items on the 3D View background.
William Reynish
william at reynish.com
Mon May 10 10:05:31 CEST 2010
Revision: 28703
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28703
Author: billrey
Date: 2010-05-10 10:05:31 +0200 (Mon, 10 May 2010)
Log Message:
-----------
Fixed a crash when dropping items on the 3D View background. Todo: Make it add a backdrop image ;)
Modified Paths:
--------------
trunk/blender/source/blender/editors/mesh/mesh_data.c
Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c 2010-05-10 06:29:34 UTC (rev 28702)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c 2010-05-10 08:05:31 UTC (rev 28703)
@@ -313,12 +313,18 @@
{
Scene *scene= CTX_data_scene(C);
Base *base= ED_view3d_give_base_under_cursor(C, event->mval);
- Image *ima;
+ Image *ima= NULL;
Mesh *me;
Object *obedit;
int exitmode= 0;
char name[32];
+ /* Check context */
+ if(base==NULL || base->object->type!=OB_MESH) {
+ BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh");
+ return OPERATOR_CANCELLED;
+ }
+
/* check input variables */
if(RNA_property_is_set(op->ptr, "path")) {
char path[FILE_MAX];
@@ -326,21 +332,17 @@
RNA_string_get(op->ptr, "path", path);
ima= BKE_add_image_file(path,
scene ? scene->r.cfra : 1);
-
- if(!ima) {
- BKE_report(op->reports, RPT_ERROR, "Not an Image.");
- return OPERATOR_CANCELLED;
- }
}
else {
RNA_string_get(op->ptr, "name", name);
ima= (Image *)find_id("IM", name);
- if(base==NULL || base->object->type!=OB_MESH || ima==NULL) {
- BKE_report(op->reports, RPT_ERROR, "Not a Mesh or no Image.");
- return OPERATOR_CANCELLED;
- }
}
+ if(!ima) {
+ BKE_report(op->reports, RPT_ERROR, "Not an Image.");
+ return OPERATOR_CANCELLED;
+ }
+
/* turn mesh in editmode */
/* BKE_mesh_get/end_editmesh: ED_uvedit_assign_image also calls this */
More information about the Bf-blender-cvs
mailing list