Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-01-15 23:34:08 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-15 23:34:08 +0400
commitc78d9a318429703463a74df5ad23722ab37e1bbb (patch)
tree1c429d4014fe4e51ec6dc1a94305c41ad4107789 /source/blender/editors/physics/particle_edit.c
parentdf72d3cc7f53b4eb8e9bdfb7c297a7e6149434f3 (diff)
Fix T38233: Right click in Particle Edit mode closes application
It was wrong memory access in selection operators when point doesn't have keys.
Diffstat (limited to 'source/blender/editors/physics/particle_edit.c')
-rw-r--r--source/blender/editors/physics/particle_edit.c102
1 files changed, 59 insertions, 43 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 808c7cc3e82..4b2eb694cc7 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -542,17 +542,19 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, int nearest)
LOOP_VISIBLE_POINTS {
if (pset->selectmode == SCE_SELECT_END) {
- /* only do end keys */
- key= point->keys + point->totkey-1;
+ if (point->totkey) {
+ /* only do end keys */
+ key= point->keys + point->totkey-1;
- if (nearest) {
- if (key_inside_circle(data, dist, KEY_WCO, &dist)) {
- nearest_point= p;
- nearest_key= point->totkey-1;
+ if (nearest) {
+ if (key_inside_circle(data, dist, KEY_WCO, &dist)) {
+ nearest_point= p;
+ nearest_key= point->totkey-1;
+ }
}
+ else if (key_inside_test(data, KEY_WCO))
+ func(data, p, point->totkey-1);
}
- else if (key_inside_test(data, KEY_WCO))
- func(data, p, point->totkey-1);
}
else {
/* do all keys */
@@ -586,12 +588,14 @@ static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selecte
LOOP_VISIBLE_POINTS {
if (pset->selectmode==SCE_SELECT_END) {
- /* only do end keys */
- key= point->keys + point->totkey - 1;
+ if (point->totkey) {
+ /* only do end keys */
+ key= point->keys + point->totkey - 1;
- if (selected==0 || key->flag & PEK_SELECT)
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist))
- func(data, p);
+ if (selected==0 || key->flag & PEK_SELECT)
+ if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist))
+ func(data, p);
+ }
}
else {
/* do all keys */
@@ -625,17 +629,19 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
LOOP_VISIBLE_POINTS {
if (pset->selectmode==SCE_SELECT_END) {
- /* only do end keys */
- key= point->keys + point->totkey-1;
-
- if (selected==0 || key->flag & PEK_SELECT) {
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
- if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
- psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat);
- invert_m4_m4(imat, mat);
- }
+ if (point->totkey) {
+ /* only do end keys */
+ key= point->keys + point->totkey-1;
- func(data, mat, imat, p, point->totkey-1, key);
+ if (selected==0 || key->flag & PEK_SELECT) {
+ if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
+ if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
+ psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat);
+ invert_m4_m4(imat, mat);
+ }
+
+ func(data, mat, imat, p, point->totkey-1, key);
+ }
}
}
}
@@ -702,9 +708,11 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit)
}
}
else if (pset->selectmode==SCE_SELECT_END) {
- key = point->keys + point->totkey - 1;
- if (key->flag & PEK_SELECT)
- sel++;
+ if (point->totkey) {
+ key = point->keys + point->totkey - 1;
+ if (key->flag & PEK_SELECT)
+ sel++;
+ }
}
}
@@ -1518,7 +1526,13 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot)
static void select_tip(PEData *data, int point_index)
{
PTCacheEditPoint *point = data->edit->points + point_index;
- PTCacheEditKey *key = &point->keys[point->totkey - 1];
+ PTCacheEditKey *key;
+
+ if (point->totkey == 0) {
+ return;
+ }
+
+ key = &point->keys[point->totkey - 1];
if (point->flag & PEP_HIDE)
return;
@@ -1739,24 +1753,26 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
}
}
else if (pset->selectmode==SCE_SELECT_END) {
- key= point->keys + point->totkey - 1;
+ if (point->totkey) {
+ key= point->keys + point->totkey - 1;
- copy_v3_v3(co, key->co);
- mul_m4_v3(mat, co);
- if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
- BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
- key_test_depth(&data, co, screen_co))
- {
- if (select) {
- if (!(key->flag & PEK_SELECT)) {
- key->flag |= PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
+ copy_v3_v3(co, key->co);
+ mul_m4_v3(mat, co);
+ if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
+ BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
+ key_test_depth(&data, co, screen_co))
+ {
+ if (select) {
+ if (!(key->flag & PEK_SELECT)) {
+ key->flag |= PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
}
- }
- else {
- if (key->flag & PEK_SELECT) {
- key->flag &= ~PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
+ else {
+ if (key->flag & PEK_SELECT) {
+ key->flag &= ~PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
}
}
}