From c760bd6e3cd4a16a4a17f9e7f718c2c9e67e9be2 Mon Sep 17 00:00:00 2001 From: Stefan Gartner Date: Wed, 14 May 2003 00:23:58 +0000 Subject: [PATCH] don't crash when adding an object after the previously selected object has been deleted (thanks to Bischofftep for pointing this out) --- source/blender/src/headerbuttons.c | 12 +++++++----- source/blender/src/toolbox.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 977bdb2fd63..1d3a24c4f3b 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -2716,11 +2716,11 @@ static uiBlock *info_filemenu(void *arg_unused) static void do_info_editmenu(void *arg, int event) { /* needed to check for valid selected objects */ - Base *base; - Object *ob; + Base *base=NULL; + Object *ob=NULL; base= BASACT; - ob= base->object; + if (base) ob= base->object; switch(event) { @@ -2777,7 +2777,8 @@ static void do_info_editmenu(void *arg, int event) case 9: /* Shear */ /* check that a valid object is selected to prevent crash */ - if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { + if (!ob) error ("Only selected objects can be sheared"); + else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { error("Only editable 3D objects can be sheared"); } else if ((base->lay & G.vd->lay)==0) { @@ -2805,7 +2806,8 @@ static void do_info_editmenu(void *arg, int event) case 10: /* Warp/Bend */ /* check that a valid object is selected to prevent crash */ - if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { + if (!ob) error("Only selected objects can be warped"); + else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { error("Only editable 3D objects can be warped"); } else if ((base->lay & G.vd->lay)==0) { diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index c9c77ee4858..0b41ef47cc8 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -568,11 +568,11 @@ void tbox_execute(void) unsigned short qual1=0, qual2=0; /* needed to check for valid selected objects */ - Base *base; - Object *ob; + Base *base=NULL; + Object *ob=NULL; base= BASACT; - ob= base->object; + if (base) ob= base->object; if(tbfunc) { tbfunc(tbval); @@ -598,11 +598,12 @@ void tbox_execute(void) /* ctrl-s (Shear): switch into editmode ### */ else if(strcmp(tbstr1, "c|s")==0) { /* check that a valid object is selected to prevent crash */ - if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { + if(!ob) error("Only selected objects can be sheared"); + else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { error("Only editable 3D objects can be sheared"); } else if ((base->lay & G.vd->lay)==0) { - error("Only objects on visible layers can be warped"); + error("Only objects on visible layers can be sheared"); } else { if (!G.obedit) { @@ -619,8 +620,9 @@ void tbox_execute(void) } } else if(strcmp(tbstr1, "W")==0) { + if (!ob) error ("Only selected objects can be warped"); /* check that a valid object is selected to prevent crash */ - if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { + else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) { error("Only editable 3D objects can be warped"); } else if ((base->lay & G.vd->lay)==0) {