add BLI_rcti,f_recenter()

fix for uninitialized variable use in radial_control_get_properties() and bad cast in bpy api's foreach_parse_args()
This commit is contained in:
Campbell Barton
2013-03-19 10:54:52 +00:00
parent 0f3515d4e2
commit d466e1d3b4
5 changed files with 18 additions and 8 deletions

View File

@@ -54,6 +54,8 @@ void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
void BLI_rctf_translate(struct rctf *rect, float x, float y);
void BLI_rcti_translate(struct rcti *rect, int x, int y);
void BLI_rcti_recenter(struct rcti *rect, int x, int y);
void BLI_rctf_recenter(struct rctf *rect, float x, float y);
void BLI_rcti_resize(struct rcti *rect, int x, int y);
void BLI_rctf_resize(struct rctf *rect, float x, float y);
void BLI_rcti_scale(rcti *rect, const float scale);

View File

@@ -296,6 +296,19 @@ void BLI_rctf_translate(rctf *rect, float x, float y)
rect->ymax += y;
}
void BLI_rcti_recenter(rcti *rect, int x, int y)
{
const int dx = x - BLI_rcti_cent_x(rect);
const int dy = y - BLI_rcti_cent_y(rect);
BLI_rcti_translate(rect, dx, dy);
}
void BLI_rctf_recenter(rctf *rect, float x, float y)
{
const float dx = x - BLI_rctf_cent_x(rect);
const float dy = y - BLI_rctf_cent_y(rect);
BLI_rctf_translate(rect, dx, dy);
}
/* change width & height around the central location */
void BLI_rcti_resize(rcti *rect, int x, int y)
{

View File

@@ -2086,12 +2086,7 @@ void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y)
}
void UI_view2d_setcenter(struct View2D *v2d, float x, float y)
{
/* get delta from current center */
float dx = x - BLI_rctf_cent_x(&v2d->cur);
float dy = y - BLI_rctf_cent_y(&v2d->cur);
/* add to cur */
BLI_rctf_translate(&v2d->cur, dx, dy);
BLI_rctf_recenter(&v2d->cur, x, y);
/* make sure that 'cur' rect is in a valid state as a result of these changes */
UI_view2d_curRect_validate(v2d);

View File

@@ -4339,7 +4339,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args,
if (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq)) {
PyErr_Format(PyExc_TypeError,
"foreach_get/set expected second argument to be a sequence or buffer, not a %.200s",
Py_TYPE(seq)->tp_name);
Py_TYPE(*seq)->tp_name);
return -1;
}

View File

@@ -3542,7 +3542,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
{
RadialControl *rc = op->customdata;
PointerRNA ctx_ptr, use_secondary_ptr;
PropertyRNA *use_secondary_prop;
PropertyRNA *use_secondary_prop = NULL;
const char *data_path;
RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);