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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-12-22 05:08:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-22 05:08:42 +0400
commit2a5cabb039faf8a4f39a5dbe0edc0497a4f72b63 (patch)
tree27f63aa843429457bfacc67ac7698f11674538f0 /source
parent78e688b71ced5ea4f34cfc4b3d913cfebaedd461 (diff)
code cleanup and minor changes
- use DummyRNA_NULL_items to replace empty enums. - replace calloc with malloc in copy_dverts since its copied over after. - add wmGesture->userdata, so operators that use gestures have somewhere to store their own data (not used yet).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/intern/mesh.c4
-rw-r--r--source/blender/editors/armature/poselib.c5
-rw-r--r--source/blender/editors/interface/view2d_ops.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c4
-rw-r--r--source/blender/editors/object/object_edit.c8
-rw-r--r--source/blender/editors/object/object_vgroup.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c24
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/windowmanager/WM_types.h3
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c3
11 files changed, 37 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 5515509e92d..7b6f57f9a09 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -152,7 +152,7 @@ void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase,
int **orco_index_ptr);
void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob);
void free_dverts(struct MDeformVert *dvert, int totvert);
-void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
+void copy_dverts(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
void BKE_mesh_delete_material_index(struct Mesh *me, short index);
void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth);
void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh);
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 960607154da..1e6f667c40b 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -430,7 +430,7 @@ void BKE_mesh_free(Mesh *me, int unlink)
if (me->edit_btmesh) MEM_freeN(me->edit_btmesh);
}
-void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
+void copy_dverts(MDeformVert *dst, const MDeformVert *src, int copycount)
{
/* Assumes dst is already set up */
int i;
@@ -442,7 +442,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
for (i = 0; i < copycount; i++) {
if (src[i].dw) {
- dst[i].dw = MEM_callocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight");
+ dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight");
memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight);
}
}
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index ae3d496b641..04815b9c33c 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -687,9 +687,6 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
void POSELIB_OT_pose_rename(wmOperatorType *ot)
{
PropertyRNA *prop;
- static EnumPropertyItem prop_poses_dummy_types[] = {
- {0, NULL, 0, NULL, NULL}
- };
/* identifiers */
ot->name = "PoseLib Rename Pose";
@@ -707,7 +704,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
/* properties */
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
- prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
+ prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to rename");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 4a3daaf71c2..006644bf366 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1020,7 +1020,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* y-axis transform */
dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
- dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin- dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
+ dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
dy *= 0.5f * BLI_rctf_size_y(&v2d->cur);
}
else {
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 4fcec28a26b..a1978f110ac 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -40,6 +40,7 @@
#include "RNA_define.h"
#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "BLI_blenlib.h"
#include "BLI_noise.h"
@@ -2528,7 +2529,6 @@ static void edbm_blend_from_shape_ui(bContext *C, wmOperator *op)
void MESH_OT_blend_from_shape(wmOperatorType *ot)
{
PropertyRNA *prop;
- static EnumPropertyItem shape_items[] = {{0, NULL, 0, NULL, NULL}};
/* identifiers */
ot->name = "Blend From Shape";
@@ -2545,7 +2545,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop = RNA_def_enum(ot->srna, "shape", shape_items, 0, "Shape", "Shape key to use for blending");
+ prop = RNA_def_enum(ot->srna, "shape", DummyRNA_NULL_items, 0, "Shape", "Shape key to use for blending");
RNA_def_enum_funcs(prop, shape_itemf);
RNA_def_float(ot->srna, "blend", 1.0f, -FLT_MAX, FLT_MAX, "Blend", "Blending factor", -2.0f, 2.0f);
RNA_def_boolean(ot->srna, "add", 1, "Add", "Add rather than blend between shapes");
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 12edb3e8edb..c9492d8f683 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1676,10 +1676,6 @@ static EnumPropertyItem game_properties_copy_operations[] = {
{0, NULL, 0, NULL, NULL}
};
-static EnumPropertyItem gameprops_items[] = {
- {0, NULL, 0, NULL, NULL}
-};
-
static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
{
Object *ob = ED_object_active_context(C);
@@ -1689,7 +1685,7 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P
int a, totitem = 0;
if (!ob)
- return gameprops_items;
+ return DummyRNA_NULL_items;
for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) {
tmp.value = a;
@@ -1760,7 +1756,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
- prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
+ prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_enum_funcs(prop, gameprops_itemf);
ot->prop = prop;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index f3e792def17..40e8fe72e8c 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -65,6 +65,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -3369,10 +3370,6 @@ void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "WT_replace_mode", WT_replace_mode_item, 1, "Replace", "");
}
-static EnumPropertyItem vgroup_items[] = {
- {0, NULL, 0, NULL, NULL}
-};
-
static int set_active_group_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
@@ -3396,7 +3393,7 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop
int a, totitem = 0;
if (!ob)
- return vgroup_items;
+ return DummyRNA_NULL_items;
for (a = 0, def = ob->defbase.first; def; def = def->next, a++) {
tmp.value = a;
@@ -3430,7 +3427,7 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop = RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active");
+ prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "Vertex group to set as active");
RNA_def_enum_funcs(prop, vgroup_itemf);
ot->prop = prop;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 9bbf99ff3cf..7134f1c2367 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -402,12 +402,28 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
return -1;
}
-static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
+static void free_vpaint_prev(VPaint *vp)
{
if (vp->vpaint_prev) {
MEM_freeN(vp->vpaint_prev);
vp->vpaint_prev = NULL;
+ vp->tot = 0;
+ }
+}
+
+static void free_wpaint_prev(VPaint *vp)
+{
+ if (vp->wpaint_prev) {
+ MEM_freeN(vp->wpaint_prev);
+ vp->wpaint_prev = NULL;
+ vp->tot = 0;
}
+}
+
+static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
+{
+ free_vpaint_prev(vp);
+
vp->tot = tot;
if (lcol == NULL || tot == 0) return;
@@ -419,10 +435,7 @@ static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
{
- if (wp->wpaint_prev) {
- free_dverts(wp->wpaint_prev, wp->tot);
- wp->wpaint_prev = NULL;
- }
+ free_wpaint_prev(wp);
if (dverts && dcount) {
@@ -432,7 +445,6 @@ static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
}
}
-
void vpaint_fill(Object *ob, unsigned int paintcol)
{
Mesh *me;
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 3b83279e09d..b2070cc2f1c 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -764,7 +764,7 @@ static EnumPropertyItem prop_id_op_types[] = {
{OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
- "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
+ "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
{OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
{OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 347f46c8166..96a7b156cd8 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -407,6 +407,9 @@ typedef struct wmGesture {
/* customdata for circle is recti, (xmin, ymin) is center, xmax radius */
/* customdata for lasso is short array */
/* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */
+
+ /* free pointer to use for operator allocs (if set, its freed on exit)*/
+ void *userdata;
} wmGesture;
/* ************** wmEvent ************************ */
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index a80386e9860..1cf44a69c17 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -113,6 +113,9 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
win->tweak = NULL;
BLI_remlink(&win->gesture, gesture);
MEM_freeN(gesture->customdata);
+ if (gesture->userdata) {
+ MEM_freeN(gesture->userdata);
+ }
MEM_freeN(gesture);
}