=bmesh= fixed unintiialized memory bug, thanks to Francisco De La Cruz

This commit is contained in:
Joseph Eagar 2011-05-03 03:05:15 +00:00
parent e64fba68a0
commit f7ff502e77
9 changed files with 52 additions and 72 deletions

@ -795,6 +795,9 @@ class USERPREF_PT_input(InputKeyMapPanel):
sub.separator() sub.separator()
sub.label(text="Loop Cut:")
sub.prop(inputs, "loopcut_finish_on_release")
sub.label(text="Orbit Style:") sub.label(text="Orbit Style:")
sub.row().prop(inputs, "view_rotate_method", expand=True) sub.row().prop(inputs, "view_rotate_method", expand=True)

@ -104,6 +104,9 @@ typedef struct tringselOpData {
int extend; int extend;
int do_cut; int do_cut;
double leftmouse_time;
wmTimer *timer;
} tringselOpData; } tringselOpData;
/* modal loop selection drawing callback */ /* modal loop selection drawing callback */
@ -189,6 +192,8 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
float co[2][3]; float co[2][3];
int i, tot=0; int i, tot=0;
memset(v, 0, sizeof(v));
if (!startedge) if (!startedge)
return; return;
@ -337,10 +342,13 @@ static void ringsel_finish(bContext *C, wmOperator *op)
} }
/* called when modal loop selection is done... */ /* called when modal loop selection is done... */
static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) static void ringsel_exit(bContext *C, wmOperator *op)
{ {
tringselOpData *lcd= op->customdata; tringselOpData *lcd= op->customdata;
if (lcd->timer)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), lcd->timer);
/* deactivate the extra drawing stuff in 3D-View */ /* deactivate the extra drawing stuff in 3D-View */
ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle); ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
@ -423,6 +431,10 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
BMEdge *edge; BMEdge *edge;
int dist = 75; int dist = 75;
/*if we're in the cut-n-slide macro, set release_confirm based on user pref*/
if (op->opm)
RNA_boolean_set(op->next->ptr, "release_confirm", U.loopcut_finish_on_release);
if(modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit)) if(modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display"); BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display");
@ -448,68 +460,6 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
return OPERATOR_RUNNING_MODAL; return OPERATOR_RUNNING_MODAL;
} }
static int ringsel_modal (bContext *C, wmOperator *op, wmEvent *event)
{
int cuts= RNA_int_get(op->ptr,"number_cuts");
tringselOpData *lcd= op->customdata;
view3d_operator_needs_opengl(C);
switch (event->type) {
case LEFTMOUSE: /* abort */ // XXX hardcoded
ED_region_tag_redraw(lcd->ar);
ringsel_exit(C, op);
return OPERATOR_FINISHED;
case RETKEY:
case RIGHTMOUSE: /* confirm */ // XXX hardcoded
if (event->val == KM_PRESS) {
/* finish */
ED_region_tag_redraw(lcd->ar);
ringsel_finish(C, op);
ringsel_exit(C, op);
ED_area_headerprint(CTX_wm_area(C), NULL);
return OPERATOR_FINISHED;
}
ED_region_tag_redraw(lcd->ar);
break;
case ESCKEY:
if (event->val == KM_RELEASE) {
/* cancel */
ED_region_tag_redraw(lcd->ar);
ED_area_headerprint(CTX_wm_area(C), NULL);
return ringcut_cancel(C, op);
}
ED_region_tag_redraw(lcd->ar);
break;
case MOUSEMOVE: { /* mouse moved somewhere to select another loop */
int dist = 75;
BMEdge *edge;
lcd->vc.mval[0] = event->mval[0];
lcd->vc.mval[1] = event->mval[1];
edge = EDBM_findnearestedge(&lcd->vc, &dist);
if (edge != lcd->eed) {
lcd->eed = edge;
ringsel_find_edge(lcd, cuts);
}
ED_region_tag_redraw(lcd->ar);
break;
}
}
/* keep going until the user confirms */
return OPERATOR_RUNNING_MODAL;
}
static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event) static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event)
{ {
int cuts= RNA_int_get(op->ptr,"number_cuts"); int cuts= RNA_int_get(op->ptr,"number_cuts");
@ -517,7 +467,6 @@ static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event)
view3d_operator_needs_opengl(C); view3d_operator_needs_opengl(C);
switch (event->type) { switch (event->type) {
case RETKEY: case RETKEY:
case LEFTMOUSE: /* confirm */ // XXX hardcoded case LEFTMOUSE: /* confirm */ // XXX hardcoded
@ -528,20 +477,37 @@ static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event)
ringsel_finish(C, op); ringsel_finish(C, op);
ringsel_exit(C, op); ringsel_exit(C, op);
return OPERATOR_FINISHED; ED_area_headerprint(CTX_wm_area(C), NULL);
return OPERATOR_FINISHED|OPERATOR_ABORT_MACRO;
} else {
lcd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER2, 0.12);
} }
ED_region_tag_redraw(lcd->ar); ED_region_tag_redraw(lcd->ar);
break; break;
case TIMER2:
/* finish */
ED_region_tag_redraw(lcd->ar);
ringsel_finish(C, op);
ringsel_exit(C, op);
ED_area_headerprint(CTX_wm_area(C), NULL);
return OPERATOR_FINISHED;
case RIGHTMOUSE: /* abort */ // XXX hardcoded case RIGHTMOUSE: /* abort */ // XXX hardcoded
ED_region_tag_redraw(lcd->ar); ED_region_tag_redraw(lcd->ar);
ringsel_exit(C, op); ringsel_exit(C, op);
ED_area_headerprint(CTX_wm_area(C), NULL);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
case ESCKEY: case ESCKEY:
if (event->val == KM_RELEASE) { if (event->val == KM_RELEASE) {
/* cancel */ /* cancel */
ED_region_tag_redraw(lcd->ar); ED_region_tag_redraw(lcd->ar);
ED_area_headerprint(CTX_wm_area(C), NULL);
return ringcut_cancel(C, op); return ringcut_cancel(C, op);
} }

@ -184,7 +184,9 @@ void ED_operatormacros_mesh(void)
ot= WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO|OPTYPE_REGISTER); ot= WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO|OPTYPE_REGISTER);
ot->description = "Cut mesh loop and slide it"; ot->description = "Cut mesh loop and slide it";
WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
RNA_boolean_set(otmacro->ptr, "launch_event", LEFTMOUSE);
ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
ot->description = "Duplicate mesh and move"; ot->description = "Duplicate mesh and move";

@ -1522,6 +1522,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->mode = mode; t->mode = mode;
t->launch_event = event ? event->type : -1; t->launch_event = event ? event->type : -1;
if (RNA_property_is_set(op->ptr, "launch_event"))
t->launch_event = RNA_int_get(op->ptr, "launch_event");
if (t->launch_event == EVT_TWEAK_R) if (t->launch_event == EVT_TWEAK_R)
{ {

@ -499,6 +499,8 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
// Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button"); /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
//RNA_def_property_flag(prop, PROP_HIDDEN); //RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_int(ot->srna, "launch_event", -1, 0, INT_MAX, "", "", -1, INT_MAX);
} }
void TRANSFORM_OT_translate(struct wmOperatorType *ot) void TRANSFORM_OT_translate(struct wmOperatorType *ot)

@ -392,7 +392,7 @@ typedef struct UserDef {
struct ColorBand coba_weight; /* from texture.h */ struct ColorBand coba_weight; /* from texture.h */
float sculpt_paint_overlay_col[3]; float sculpt_paint_overlay_col[3];
int pad3; int loopcut_finish_on_release;
char author[80]; /* author name for file formats supporting it */ char author[80]; /* author name for file formats supporting it */
} UserDef; } UserDef;

@ -313,6 +313,7 @@ typedef struct wmOperator {
#define OPERATOR_PASS_THROUGH 8 #define OPERATOR_PASS_THROUGH 8
/* in case operator got executed outside WM code... like via fileselect */ /* in case operator got executed outside WM code... like via fileselect */
#define OPERATOR_HANDLED 16 #define OPERATOR_HANDLED 16
#define OPERATOR_ABORT_MACRO 32
/* wmOperator flag */ /* wmOperator flag */
#define OP_GRAB_POINTER 1 #define OP_GRAB_POINTER 1

@ -2680,6 +2680,10 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_enum_items(prop, view_zoom_axes); RNA_def_property_enum_items(prop, view_zoom_axes);
RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on"); RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
prop= RNA_def_property(srna, "loopcut_finish_on_release", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "loopcut_finish_on_release", 1);
RNA_def_property_ui_text(prop, "End Loopcut Slide On Release", "End Loopcut Slide On Mouse Release, a 'click-drag-and-hold' workflow");
prop= RNA_def_property(srna, "invert_mouse_wheel_zoom", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "invert_mouse_wheel_zoom", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming"); RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");

@ -213,7 +213,7 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
if(opm->type->exec) { if(opm->type->exec) {
retval= opm->type->exec(C, opm); retval= opm->type->exec(C, opm);
if (retval & OPERATOR_FINISHED) { if ((retval & OPERATOR_FINISHED) && !(retval & OPERATOR_ABORT_MACRO)) {
MacroData *md = op->customdata; MacroData *md = op->customdata;
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
} else { } else {
@ -238,7 +238,7 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event,
BLI_movelisttolist(&op->reports->list, &opm->reports->list); BLI_movelisttolist(&op->reports->list, &opm->reports->list);
if (retval & OPERATOR_FINISHED) { if ((retval & OPERATOR_FINISHED) && !(retval & OPERATOR_ABORT_MACRO)) {
MacroData *md = op->customdata; MacroData *md = op->customdata;
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
} else { } else {
@ -266,7 +266,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event)
retval = opm->type->modal(C, opm, event); retval = opm->type->modal(C, opm, event);
/* if this one is done but it's not the last operator in the macro */ /* if this one is done but it's not the last operator in the macro */
if ((retval & OPERATOR_FINISHED) && opm->next) { if (opm->next && (retval & OPERATOR_FINISHED) && !(retval & OPERATOR_ABORT_MACRO)) {
MacroData *md = op->customdata; MacroData *md = op->customdata;
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */