Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2017-08-23 16:10:45 +10:00
commit 58a4c767a1
27 changed files with 188 additions and 65 deletions

@ -61,10 +61,8 @@ def replace_line(f, i, text, keep_indent=True):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.git'
if dirpath.startswith("."):
continue
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if filename_check is None or filename_check(filename):

@ -84,10 +84,8 @@ def init(cmake_path):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)

@ -2235,7 +2235,7 @@ static void ntree_interface_type_create(bNodeTree *ntree)
/* register a subtype of PropertyGroup */
srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup);
RNA_def_struct_ui_text(srna, name, description);
RNA_def_struct_duplicate_pointers(srna);
RNA_def_struct_duplicate_pointers(&BLENDER_RNA, srna);
/* associate the RNA type with the node tree */
ntree->interface_type = srna;
@ -2274,10 +2274,10 @@ StructRNA *ntreeInterfaceTypeGet(bNodeTree *ntree, int create)
ntree_interface_identifier(ntree, base, identifier, sizeof(identifier), name, description);
/* rename the RNA type */
RNA_def_struct_free_pointers(srna);
RNA_def_struct_free_pointers(&BLENDER_RNA, srna);
RNA_def_struct_identifier(&BLENDER_RNA, srna, identifier);
RNA_def_struct_ui_text(srna, name, description);
RNA_def_struct_duplicate_pointers(srna);
RNA_def_struct_duplicate_pointers(&BLENDER_RNA, srna);
}
}
else if (create) {

@ -91,6 +91,7 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfre
void BLI_ghash_reserve(GHash *gh, const unsigned int nentries_reserve);
void BLI_ghash_insert(GHash *gh, void *key, void *val);
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
void *BLI_ghash_replace_key(GHash *gh, void *key);
void *BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT;
void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
@ -249,6 +250,7 @@ void BLI_gset_insert(GSet *gh, void *key);
bool BLI_gset_add(GSet *gs, void *key);
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key);
bool BLI_gset_reinsert(GSet *gh, void *key, GSetKeyFreeFP keyfreefp);
void *BLI_gset_replace_key(GSet *gs, void *key);
bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp);

@ -762,6 +762,28 @@ bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreef
return ghash_insert_safe(gh, key, val, true, keyfreefp, valfreefp);
}
/**
* Replaces the key of an item in the \a gh.
*
* Use when a key is re-allocated or it's memory location is changed.
*
* \returns The previous key or NULL if not found, the caller may free if it's needed.
*/
void *BLI_ghash_replace_key(GHash *gh, void *key)
{
const unsigned int hash = ghash_keyhash(gh, key);
const unsigned int bucket_index = ghash_bucket_index(gh, hash);
GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
if (e != NULL) {
void *key_prev = e->e.key;
e->e.key = key;
return key_prev;
}
else {
return NULL;
}
}
/**
* Lookup the value of \a key in \a gh.
*
@ -1434,6 +1456,18 @@ bool BLI_gset_reinsert(GSet *gs, void *key, GSetKeyFreeFP keyfreefp)
return ghash_insert_safe_keyonly((GHash *)gs, key, true, keyfreefp);
}
/**
* Replaces the key to the set if it's found.
* Matching #BLI_ghash_replace_key
*
* \returns The old key or NULL if not found.
*/
void *BLI_gset_replace_key(GSet *gs, void *key)
{
return BLI_ghash_replace_key((GHash *)gs, key);
}
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
{
return BLI_ghash_remove((GHash *)gs, key, keyfreefp, NULL);

@ -284,6 +284,8 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
new_stroke->triangles = MEM_dupallocN(gps_from->triangles);
new_stroke->tot_triangles = 0;
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
if (valid) {
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
@ -302,6 +304,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points));
new_stroke->tot_triangles = 0;
new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles));
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
}
/* add to strokes */
@ -986,6 +989,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
new_stroke->triangles = MEM_dupallocN(gps_from->triangles);
new_stroke->tot_triangles = 0;
new_stroke->flag |= GP_STROKE_RECALC_CACHES;
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
if (gps_from->totpoints > gps_to->totpoints) {

@ -7063,7 +7063,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
}
uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
mt = WM_menutype_find("WM_MT_button_context", false);
mt = WM_menutype_find("WM_MT_button_context", true);
if (mt) {
Menu menu = {NULL};
menu.layout = uiLayoutColumn(layout, false);

@ -799,6 +799,8 @@ const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);
bool RNA_struct_available_or_report(struct ReportList *reports, const char *identifier);
/* Properties
*
* Access to struct properties. All this works with RNA pointers rather than

@ -225,8 +225,8 @@ void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
/* Memory management */
void RNA_def_struct_duplicate_pointers(StructRNA *srna);
void RNA_def_struct_free_pointers(StructRNA *srna);
void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna);
void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna);
void RNA_def_func_duplicate_pointers(FunctionRNA *func);
void RNA_def_func_free_pointers(FunctionRNA *func);
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop);

@ -290,6 +290,10 @@ StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports,
return NULL;
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
return RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup); /* XXX */
}

@ -831,6 +831,38 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, i
return NULL;
}
bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
{
const StructRNA *srna_exists = RNA_struct_find(identifier);
if (UNLIKELY(srna_exists != NULL)) {
/* Use comprehensive string construction since this is such a rare occurrence
* and information here may cut down time troubleshooting. */
DynStr *dynstr = BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "Type identifier '%s' is already in use: '", identifier);
BLI_dynstr_append(dynstr, srna_exists->identifier);
int i = 0;
if (srna_exists->base) {
for (const StructRNA *base = srna_exists->base; base; base = base->base) {
BLI_dynstr_append(dynstr, "(");
BLI_dynstr_append(dynstr, base->identifier);
i += 1;
}
while (i--) {
BLI_dynstr_append(dynstr, ")");
}
}
BLI_dynstr_append(dynstr, "'.");
char *result = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
BKE_report(reports, RPT_ERROR, result);
MEM_freeN(result);
return false;
}
else {
return true;
}
}
/* Property Information */
const char *RNA_property_identifier(PropertyRNA *prop)

@ -271,8 +271,12 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v
/* check if we have registered this info before, and remove it */
ksi = ANIM_keyingset_info_find_name(dummyksi.idname);
if (ksi && ksi->ext.srna)
if (ksi && ksi->ext.srna) {
rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new KeyingSetInfo type */
ksi = MEM_callocN(sizeof(KeyingSetInfo), "python keying set info");

@ -156,7 +156,7 @@ static void rna_brna_structs_remove_and_free(BlenderRNA *brna, StructRNA *srna)
}
}
RNA_def_struct_free_pointers(srna);
RNA_def_struct_free_pointers(NULL, srna);
if (srna->flag & STRUCT_RUNTIME) {
rna_freelinkN(&brna->structs, srna);
@ -3313,21 +3313,37 @@ void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
/* Memory management */
#ifdef RNA_RUNTIME
void RNA_def_struct_duplicate_pointers(StructRNA *srna)
void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna)
{
if (srna->identifier) srna->identifier = BLI_strdup(srna->identifier);
if (srna->name) srna->name = BLI_strdup(srna->name);
if (srna->description) srna->description = BLI_strdup(srna->description);
if (srna->identifier) {
srna->identifier = BLI_strdup(srna->identifier);
BLI_ghash_replace_key(brna->structs_map, (void *)srna->identifier);
}
if (srna->name) {
srna->name = BLI_strdup(srna->name);
}
if (srna->description) {
srna->description = BLI_strdup(srna->description);
}
srna->flag |= STRUCT_FREE_POINTERS;
}
void RNA_def_struct_free_pointers(StructRNA *srna)
void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna)
{
if (srna->flag & STRUCT_FREE_POINTERS) {
if (srna->identifier) MEM_freeN((void *)srna->identifier);
if (srna->name) MEM_freeN((void *)srna->name);
if (srna->description) MEM_freeN((void *)srna->description);
if (srna->identifier) {
if (brna != NULL) {
BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
}
MEM_freeN((void *)srna->identifier);
}
if (srna->name) {
MEM_freeN((void *)srna->name);
}
if (srna->description) {
MEM_freeN((void *)srna->description);
}
}
}

@ -634,8 +634,12 @@ static StructRNA *rna_NodeTree_register(
/* check if we have registered this tree type before, and remove it */
nt = ntreeTypeFind(dummynt.idname);
if (nt)
if (nt) {
rna_NodeTree_unregister(bmain, nt->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new node tree type */
nt = MEM_callocN(sizeof(bNodeTreeType), "node tree type");
@ -1393,11 +1397,18 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
identifier, (int)sizeof(dummynt.idname));
return NULL;
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* check if we have registered this node type before, and remove it */
nt = nodeTypeFind(dummynt.idname);
if (nt)
if (nt) {
rna_Node_unregister(bmain, nt->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new node type */
nt = MEM_callocN(sizeof(bNodeType), "node type");

@ -341,6 +341,9 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
break;
}
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new engine type */
et = MEM_callocN(sizeof(RenderEngineType), "python render engine");

@ -229,6 +229,9 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
break;
}
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new panel type */
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
@ -488,8 +491,12 @@ static StructRNA *rna_UIList_register(Main *bmain, ReportList *reports, void *da
/* check if we have registered this uilist type before, and remove it */
ult = WM_uilisttype_find(dummyult.idname, true);
if (ult && ult->ext.srna)
if (ult && ult->ext.srna) {
rna_UIList_unregister(bmain, ult->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new menu type */
ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist");
@ -592,6 +599,9 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da
break;
}
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new header type */
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
@ -712,8 +722,12 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data
/* check if we have registered this menu type before, and remove it */
mt = WM_menutype_find(dummymt.idname, true);
if (mt && mt->ext.srna)
if (mt && mt->ext.srna) {
rna_Menu_unregister(bmain, mt->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new menu type */
if (_menu_descr[0]) {

@ -615,10 +615,11 @@ static StructRNA *rna_AddonPref_register(Main *bmain, ReportList *reports, void
/* check if we have registered this header type before, and remove it */
apt = BKE_addon_pref_type_find(dummyaddon.module, true);
if (apt) {
if (apt->ext.srna) {
if (apt && apt->ext.srna) {
rna_AddonPref_unregister(bmain, apt->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
/* create a new header type */

@ -1239,6 +1239,16 @@ static StructRNA *rna_Operator_register(
if (validate(&dummyotr, data, have_function) != 0)
return NULL;
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->ext.srna)
rna_Operator_unregister(bmain, ot->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
{ /* convert foo.bar to FOO_OT_bar
* allocate the description and the idname in 1 go */
@ -1306,13 +1316,6 @@ static StructRNA *rna_Operator_register(
}
}
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->ext.srna)
rna_Operator_unregister(bmain, ot->ext.srna);
}
/* XXX, this doubles up with the operator name [#29666]
* for now just remove from dir(bpy.types) */
@ -1415,6 +1418,16 @@ static StructRNA *rna_MacroOperator_register(
return NULL;
}
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->ext.srna)
rna_Operator_unregister(bmain, ot->ext.srna);
}
if (!RNA_struct_available_or_report(reports, identifier)) {
return NULL;
}
{ /* convert foo.bar to FOO_OT_bar
* allocate the description and the idname in 1 go */
const uint idname_len = strlen(temp_buffers.idname) + 4;
@ -1441,13 +1454,6 @@ static StructRNA *rna_MacroOperator_register(
dummyot.undo_group = ch;
}
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->ext.srna)
rna_Operator_unregister(bmain, ot->ext.srna);
}
/* XXX, this doubles up with the operator name [#29666]
* for now just remove from dir(bpy.types) */

@ -2880,7 +2880,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *update_cb = NULL, *poll_cb = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kw,
"s#O|ssO!OOO:PointerProperty",
"s#O|ssO!OO:PointerProperty",
(char **)kwlist, &id, &id_len,
&type, &name, &description,
&PySet_Type, &pyopts,

@ -53,10 +53,8 @@ def is_source_any(filename):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if filename_check is None or filename_check(filename):

@ -72,10 +72,8 @@ def batch_import(
def file_generator(path):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if pattern_match(filename):

@ -93,9 +93,8 @@ def addon_modules_sorted():
def source_list(path, filename_check=None):
from os.path import join
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)

@ -100,10 +100,8 @@ def blend_list(mainpath):
def file_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn'
if dirpath.startswith("."):
continue
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)