From 72279e1c9247c8779f75f495ed7fa99908209411 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Nov 2010 03:45:35 +0000 Subject: fix for RNA ranges exceeding the range of the type (INT_MAX used on short's for eg). --- source/blender/editors/curve/editcurve.c | 5 ++++- source/blender/makesdna/DNA_curve_types.h | 6 +++--- source/blender/makesdna/DNA_image_types.h | 15 +++++++++------ source/blender/makesdna/DNA_scene_types.h | 4 ++-- source/blender/makesdna/DNA_view3d_types.h | 4 ++-- source/blender/makesrna/intern/rna_curve.c | 8 ++++---- source/blender/makesrna/intern/rna_image.c | 2 +- source/blender/makesrna/intern/rna_particle.c | 6 +++--- source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 4 ++-- source/blender/makesrna/intern/rna_world.c | 2 +- 11 files changed, 32 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 1679775057c..ceb1ace849e 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4117,7 +4117,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) invert_m3_m3(imat,mat); findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); - if(bezt==0 && bp==0) return OPERATOR_CANCELLED; + + if((nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) { + return OPERATOR_CANCELLED; + } if(nu->type == CU_BEZIER) { /* which bezpoint? */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 50579660806..ba357b575d5 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -189,11 +189,11 @@ typedef struct Curve { float rot[3]; short texflag, pad1; /* keep a short because of give_obdata_texspace() */ - - short drawflag, twist_mode, pad[2]; + short drawflag, twist_mode; float twist_smooth, smallcaps_scale; - short pathlen, totcol; + int pathlen; + short pad, totcol; short flag, bevresol; float width, ext1, ext2; diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index b58bd259983..3df3c8b41c6 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -44,17 +44,20 @@ struct GPUTexture; /* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */ /* should be used in conjunction with an ID * to Image. */ typedef struct ImageUser { + struct Scene *scene; /* to retrieve render result */ + int framenr; /* movies, sequences: current to display */ int frames; /* total amount of frames to use */ int offset, sfra; /* offset within movie, start frame in global time */ - short fie_ima, cycl; /* fields/image in movie, cyclic flag */ - short flag, ok; - + char fie_ima, cycl; /* fields/image in movie, cyclic flag */ + char ok, pad; + short multi_index, layer, pass; /* listbase indices, for menu browsing or retrieve buffer */ - /* short menunr; */ /* localized menu entry, for handling browse event */ - short pad; - struct Scene *scene; /* to retrieve render result */ + short flag; + + int pad2; + } ImageUser; /* iuser->flag */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index eedcf36c584..7b8f86a302a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -221,8 +221,8 @@ typedef struct RenderData { float edgeR, edgeG, edgeB; short fullscreen, xplay, yplay, freqplay; /* standalone player */ // XXX deprecated since 2.5 - short depth, attrib, rt2; /* standalone player */ // XXX deprecated since 2.5 - short frame_step; /* frames to jump during render/playback */ + short depth, attrib; /* standalone player */ // XXX deprecated since 2.5 + int frame_step; /* frames to jump during render/playback */ short stereomode; /* standalone player stereo settings */ // XXX deprecated since 2.5 diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 77b42bbed62..dcc620463c9 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -94,9 +94,9 @@ typedef struct RegionView3D { float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */ float pixsize; float ofs[3]; - short camzoom, viewbut; + short camzoom; short twdrawflag; - short pad; + int pad; short rflag, viewlock; short persp; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index ea08930e849..ef7910745a7 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1249,7 +1249,7 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 64, 1, 0); RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction"); RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data"); @@ -1257,20 +1257,20 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_ui_range(prop, 1, 64, 1, 0); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction"); RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data"); prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu_ren"); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 0, 64, 1, 0); RNA_def_property_ui_text(prop, "Render Resolution U", "Surface resolution in U direction used while rendering. Zero skips this property"); prop= RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv_ren"); RNA_def_property_ui_range(prop, 0, 64, 1, 0); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property"); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 62e7b516e9e..3874103ef7a 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -280,7 +280,7 @@ static void rna_def_imageuser(BlenderRNA *brna) prop= RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "fie_ima"); - RNA_def_property_range(prop, 1, MAXFRAMEF); + RNA_def_property_range(prop, 1, 200); RNA_def_property_ui_text(prop, "Fields per Frame", "The number of fields per rendered frame (2 fields is 1 image)"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 5481f60e81c..b9703392c10 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -942,7 +942,7 @@ static void rna_def_particle_dupliweight(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_text(prop, "Count", "The number of times this object is repeated with respect to other objects"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); } @@ -1426,7 +1426,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) //TODO: not found in UI, readonly? prop= RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, INT_MAX);//TODO:min,max + RNA_def_property_range(prop, 0, SHRT_MAX);//TODO:min,max RNA_def_property_ui_text(prop, "Keys Step", ""); /* adaptive path rendering */ @@ -2142,7 +2142,7 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "reactor_target_particle_system", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "target_psys"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Reactor Target Particle System", "For reactor systems, index of particle system on the target object"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 0cb4a251d0c..0d2421e276c 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1213,7 +1213,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "etch_subdivision_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "skgen_subdivision_number"); - RNA_def_property_range(prop, 1, 10000); + RNA_def_property_range(prop, 1, 255); RNA_def_property_ui_text(prop, "Subdivisions", "Number of bones in the subdivided stroke"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 8f83e0b39a4..0b4d87ed642 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -420,7 +420,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "default_key_count", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "totaddkey"); - RNA_def_property_range(prop, 2, INT_MAX); + RNA_def_property_range(prop, 2, SHRT_MAX); RNA_def_property_ui_range(prop, 2, 20, 10, 3); RNA_def_property_ui_text(prop, "Keys", "How many keys to make new particles with"); @@ -482,7 +482,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "steps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "step"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 50, 10, 3); RNA_def_property_ui_text(prop, "Steps", "Brush steps"); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 969536972f7..9e74d751f69 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -285,7 +285,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces to use for approximate ambient occlusion"); RNA_def_property_update(prop, 0, "rna_World_update"); -- cgit v1.2.3