diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-10 23:16:56 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-10 23:16:56 +0300 |
commit | 6a15ac70b6558873dc15aa2172024477362fc33f (patch) | |
tree | f18ea53d09cd6521da6ab2d87cf032e87da61af3 /source/blender | |
parent | b36a05bb7e794335e3415594c41d3986cdc815e8 (diff) |
[#20581] Lasso tool ends unexpectedly
Don't limit lasso to 1024 points, just realloc array with increased size when current limit is reached.
Also silence two stupid warnings.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 20 | ||||
-rw-r--r-- | source/blender/windowmanager/wm.h | 2 |
4 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 9f52cde27e1..442177ef7ba 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -286,6 +286,7 @@ typedef struct wmGesture { int type; /* gesture type define */ int swinid; /* initial subwindow id where it started */ int points; /* optional, amount of points stored */ + int size; /* optional, maximum amount of points stored */ void *customdata; /* customdata for border is a recti */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index a57421560a6..80d6869067a 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -91,10 +91,11 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) } else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) { short *lasso; - gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MAX_POINTS, "lasso points"); + gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MIN_POINTS, "lasso points"); lasso[0] = event->x - sx; lasso[1] = event->y - sy; gesture->points= 1; + gesture->size = WM_LASSO_MIN_POINTS; } return gesture; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1d4e4eb2d39..69b3cbc51ab 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -962,7 +962,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse ver_width = BLF_width(version_str); rev_width = BLF_width(revision_str); -#endif NAN_BUILDINFO +#endif //NAN_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); @@ -973,7 +973,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse #ifdef NAN_BUILDINFO uiDefBut(block, LABEL, 0, version_str, 500-ver_width, 282-24, ver_width, 20, NULL, 0, 0, 0, 0, NULL); uiDefBut(block, LABEL, 0, revision_str, 500-rev_width, 282-36, rev_width, 20, NULL, 0, 0, 0, 0, NULL); -#endif NAN_BUILDINFO +#endif //NAN_BUILDINFO uiBlockSetEmboss(block, UI_EMBOSSP); @@ -2152,17 +2152,23 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); - if(gesture->points < WM_LASSO_MAX_POINTS) { + + if(gesture->points == gesture->size) { + short *old_lasso = gesture->customdata; + gesture->customdata= MEM_callocN(2*sizeof(short)*(gesture->size + WM_LASSO_MIN_POINTS), "lasso points"); + memcpy(gesture->customdata, old_lasso, 2*sizeof(short)*gesture->size); + gesture->size = gesture->size + WM_LASSO_MIN_POINTS; + MEM_freeN(old_lasso); + printf("realloc\n"); + } + + { short *lasso= gesture->customdata; lasso += 2 * gesture->points; lasso[0] = event->x - sx; lasso[1] = event->y - sy; gesture->points++; } - else { - gesture_lasso_apply(C, op, event->type); - return OPERATOR_FINISHED; - } break; case LEFTMOUSE: diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 9b888a0e347..14483915083 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -59,7 +59,7 @@ void wm_window_keymap(wmKeyConfig *keyconf); void wm_tweakevent_test(bContext *C, wmEvent *event, int action); /* wm_gesture.c */ -#define WM_LASSO_MAX_POINTS 1024 +#define WM_LASSO_MIN_POINTS 1024 void wm_gesture_draw(struct wmWindow *win); int wm_gesture_evaluate(bContext *C, wmGesture *gesture); void wm_gesture_tag_redraw(bContext *C); |