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
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2020-07-03 22:22:41 +0300
committerSebastian Parborg <darkdefende@gmail.com>2020-07-03 22:23:33 +0300
commitd7dbf90a0252ae09649b9033d1f199fa6acd8d07 (patch)
treeb968d8183fe6456dcfe42f6587cc786c90d56182
parent185fe9cd8bb177070ce8aecaa036d9880cce380e (diff)
Clang-tidy: Enable braces-around-statements warning
-rw-r--r--.clang-tidy1
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c159
-rw-r--r--source/blender/blenlib/intern/fileops.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c12
-rw-r--r--source/blender/editors/animation/anim_filter.c9
-rw-r--r--source/blender/editors/interface/interface_templates.c12
-rw-r--r--source/blender/editors/object/object_vgroup.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c9
-rw-r--r--source/blender/makesrna/intern/makesrna.c71
10 files changed, 190 insertions, 104 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 733092e5e8e..df5fc05bfd1 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -13,7 +13,6 @@ Checks: >
-readability-misleading-indentation,
-readability-else-after-return,
- -readability-braces-around-statements,
-readability-inconsistent-declaration-parameter-name,
-readability-non-const-parameter,
-readability-redundant-preprocessor,
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 305952c9503..5e523204020 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -198,10 +198,12 @@ print_error(const char *str, ...)
va_end(ap);
buf[sizeof(buf) - 1] = '\0';
- if (error_callback)
+ if (error_callback) {
error_callback(buf);
- else
+ }
+ else {
fputs(buf, stderr);
+ }
}
static pthread_mutex_t thread_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -261,13 +263,16 @@ void *MEM_guarded_dupallocN(const void *vmemh)
memh--;
#ifndef DEBUG_MEMDUPLINAME
- if (LIKELY(memh->alignment == 0))
+ if (LIKELY(memh->alignment == 0)) {
newp = MEM_guarded_mallocN(memh->len, "dupli_alloc");
- else
+ }
+ else {
newp = MEM_guarded_mallocN_aligned(memh->len, (size_t)memh->alignment, "dupli_alloc");
+ }
- if (newp == NULL)
+ if (newp == NULL) {
return NULL;
+ }
#else
{
MemHead *nmemh;
@@ -450,8 +455,9 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
if (LIKELY(memh)) {
make_memhead_header(memh, len, str);
- if (UNLIKELY(malloc_debug_memset && len))
+ if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
+ }
#ifdef DEBUG_MEMCOUNTER
if (_mallocn_count == DEBUG_MEMCOUNTER_ERROR_VAL)
@@ -522,8 +528,9 @@ void *MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str)
make_memhead_header(memh, len, str);
memh->alignment = (short)alignment;
- if (UNLIKELY(malloc_debug_memset && len))
+ if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
+ }
#ifdef DEBUG_MEMCOUNTER
if (_mallocn_count == DEBUG_MEMCOUNTER_ERROR_VAL)
@@ -601,12 +608,15 @@ static int compare_len(const void *p1, const void *p2)
const MemPrintBlock *pb1 = (const MemPrintBlock *)p1;
const MemPrintBlock *pb2 = (const MemPrintBlock *)p2;
- if (pb1->len < pb2->len)
+ if (pb1->len < pb2->len) {
return 1;
- else if (pb1->len == pb2->len)
+ }
+ else if (pb1->len == pb2->len) {
return 0;
- else
+ }
+ else {
return -1;
+ }
}
void MEM_guarded_printmemlist_stats(void)
@@ -636,8 +646,9 @@ void MEM_guarded_printmemlist_stats(void)
totpb = 0;
membl = membase->first;
- if (membl)
+ if (membl) {
membl = MEMNEXT(membl);
+ }
while (membl && pb) {
pb->name = membl->name;
@@ -654,10 +665,12 @@ void MEM_guarded_printmemlist_stats(void)
}
#endif
- if (membl->next)
+ if (membl->next) {
membl = MEMNEXT(membl->next);
- else
+ }
+ else {
break;
+ }
}
/* sort by name and add together blocks with the same name */
@@ -737,8 +750,9 @@ static void MEM_guarded_printmemlist_internal(int pydict)
mem_lock_thread();
membl = membase->first;
- if (membl)
+ if (membl) {
membl = MEMNEXT(membl);
+ }
if (pydict) {
print_error("# membase_debug.py\n");
@@ -771,10 +785,12 @@ static void MEM_guarded_printmemlist_internal(int pydict)
print_memhead_backtrace(membl);
#endif
}
- if (membl->next)
+ if (membl->next) {
membl = MEMNEXT(membl->next);
- else
+ }
+ else {
break;
+ }
}
if (pydict) {
print_error("]\n\n");
@@ -791,15 +807,18 @@ void MEM_guarded_callbackmemlist(void (*func)(void *))
mem_lock_thread();
membl = membase->first;
- if (membl)
+ if (membl) {
membl = MEMNEXT(membl);
+ }
while (membl) {
func(membl + 1);
- if (membl->next)
+ if (membl->next) {
membl = MEMNEXT(membl->next);
- else
+ }
+ else {
break;
+ }
}
mem_unlock_thread();
@@ -890,18 +909,21 @@ void MEM_guarded_freeN(void *vmemh)
MemorY_ErroR(memh->name, "end corrupt");
name = check_memlist(memh);
if (name != NULL) {
- if (name != memh->name)
+ if (name != memh->name) {
MemorY_ErroR(name, "is also corrupt");
+ }
}
}
else {
mem_lock_thread();
name = check_memlist(memh);
mem_unlock_thread();
- if (name == NULL)
+ if (name == NULL) {
MemorY_ErroR("free", "pointer not in memlist");
- else
+ }
+ else {
MemorY_ErroR(name, "error in header");
+ }
}
totblock--;
@@ -928,10 +950,12 @@ static void addtail(volatile localListBase *listbase, void *vlink)
link->next = NULL;
link->prev = listbase->last;
- if (listbase->last)
+ if (listbase->last) {
((struct localLink *)listbase->last)->next = link;
- if (listbase->first == NULL)
+ }
+ if (listbase->first == NULL) {
listbase->first = link;
+ }
listbase->last = link;
}
@@ -948,15 +972,19 @@ static void remlink(volatile localListBase *listbase, void *vlink)
return;
#endif
- if (link->next)
+ if (link->next) {
link->next->prev = link->prev;
- if (link->prev)
+ }
+ if (link->prev) {
link->prev->next = link->next;
+ }
- if (listbase->last == link)
+ if (listbase->last == link) {
listbase->last = link->prev;
- if (listbase->first == link)
+ }
+ if (listbase->first == link) {
listbase->first = link->next;
+ }
}
static void rem_memblock(MemHead *memh)
@@ -964,10 +992,12 @@ static void rem_memblock(MemHead *memh)
mem_lock_thread();
remlink(membase, &memh->next);
if (memh->prev) {
- if (memh->next)
+ if (memh->next) {
MEMNEXT(memh->prev)->nextname = MEMNEXT(memh->next)->name;
- else
+ }
+ else {
MEMNEXT(memh->prev)->nextname = NULL;
+ }
}
mem_unlock_thread();
@@ -979,8 +1009,9 @@ static void rem_memblock(MemHead *memh)
free((char *)memh->name);
#endif
- if (UNLIKELY(malloc_debug_memset && memh->len))
+ if (UNLIKELY(malloc_debug_memset && memh->len)) {
memset(memh + 1, 255, memh->len);
+ }
if (LIKELY(memh->alignment == 0)) {
free(memh);
}
@@ -1004,78 +1035,100 @@ static const char *check_memlist(MemHead *memh)
const char *name;
forw = membase->first;
- if (forw)
+ if (forw) {
forw = MEMNEXT(forw);
+ }
forwok = NULL;
while (forw) {
- if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2)
+ if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) {
break;
+ }
forwok = forw;
- if (forw->next)
+ if (forw->next) {
forw = MEMNEXT(forw->next);
- else
+ }
+ else {
forw = NULL;
+ }
}
back = (MemHead *)membase->last;
- if (back)
+ if (back) {
back = MEMNEXT(back);
+ }
backok = NULL;
while (back) {
- if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2)
+ if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) {
break;
+ }
backok = back;
- if (back->prev)
+ if (back->prev) {
back = MEMNEXT(back->prev);
- else
+ }
+ else {
back = NULL;
+ }
}
- if (forw != back)
+ if (forw != back) {
return ("MORE THAN 1 MEMORYBLOCK CORRUPT");
+ }
if (forw == NULL && back == NULL) {
/* no wrong headers found then but in search of memblock */
forw = membase->first;
- if (forw)
+ if (forw) {
forw = MEMNEXT(forw);
+ }
forwok = NULL;
while (forw) {
- if (forw == memh)
+ if (forw == memh) {
break;
- if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2)
+ }
+ if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) {
break;
+ }
forwok = forw;
- if (forw->next)
+ if (forw->next) {
forw = MEMNEXT(forw->next);
- else
+ }
+ else {
forw = NULL;
+ }
}
- if (forw == NULL)
+ if (forw == NULL) {
return NULL;
+ }
back = (MemHead *)membase->last;
- if (back)
+ if (back) {
back = MEMNEXT(back);
+ }
backok = NULL;
while (back) {
- if (back == memh)
+ if (back == memh) {
break;
- if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2)
+ }
+ if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) {
break;
+ }
backok = back;
- if (back->prev)
+ if (back->prev) {
back = MEMNEXT(back->prev);
- else
+ }
+ else {
back = NULL;
+ }
}
}
- if (forwok)
+ if (forwok) {
name = forwok->nextname;
- else
+ }
+ else {
name = "No name found";
+ }
if (forw == memh) {
/* to be sure but this block is removed from the list */
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index b9133edcae3..e87350ecbb6 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -177,8 +177,9 @@ size_t BLI_gzip_mem_to_file_at_pos(
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, compression_level);
- if (ret != Z_OK)
+ if (ret != Z_OK) {
return 0;
+ }
strm.avail_in = len;
strm.next_in = (Bytef *)buf;
@@ -224,8 +225,9 @@ size_t BLI_ungzip_file_to_mem_at_pos(void *buf, size_t len, FILE *file, size_t g
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
- if (ret != Z_OK)
+ if (ret != Z_OK) {
return 0;
+ }
do {
strm.avail_in = fread(in, 1, chunk, file);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 971d67d7d9a..836260c46e5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2111,8 +2111,9 @@ void blo_end_volume_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->volumemap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (; volume; volume = volume->id.next) {
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 843b8400a32..79c465c1f33 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -2842,8 +2842,9 @@ static void *acf_dshair_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (hair->adt)
+ if (hair->adt) {
return GET_ACF_FLAG_PTR(hair->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2922,8 +2923,9 @@ static void *acf_dspointcloud_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (pointcloud->adt)
+ if (pointcloud->adt) {
return GET_ACF_FLAG_PTR(pointcloud->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -3002,8 +3004,9 @@ static void *acf_dsvolume_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (volume->adt)
+ if (volume->adt) {
return GET_ACF_FLAG_PTR(volume->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -3080,8 +3083,9 @@ static void *acf_dssimulation_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (simulation->adt)
+ if (simulation->adt) {
return GET_ACF_FLAG_PTR(simulation->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 08be6c72bbc..bbb673caa71 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -2601,8 +2601,9 @@ static size_t animdata_filter_ds_obdata(
{
Hair *hair = (Hair *)ob->data;
- if (ads->filterflag2 & ADS_FILTER_NOHAIR)
+ if (ads->filterflag2 & ADS_FILTER_NOHAIR) {
return 0;
+ }
type = ANIMTYPE_DSHAIR;
expanded = FILTER_HAIR_OBJD(hair);
@@ -2612,8 +2613,9 @@ static size_t animdata_filter_ds_obdata(
{
PointCloud *pointcloud = (PointCloud *)ob->data;
- if (ads->filterflag2 & ADS_FILTER_NOPOINTCLOUD)
+ if (ads->filterflag2 & ADS_FILTER_NOPOINTCLOUD) {
return 0;
+ }
type = ANIMTYPE_DSPOINTCLOUD;
expanded = FILTER_POINTS_OBJD(pointcloud);
@@ -2623,8 +2625,9 @@ static size_t animdata_filter_ds_obdata(
{
Volume *volume = (Volume *)ob->data;
- if (ads->filterflag2 & ADS_FILTER_NOVOLUME)
+ if (ads->filterflag2 & ADS_FILTER_NOVOLUME) {
return 0;
+ }
type = ANIMTYPE_DSVOLUME;
expanded = FILTER_VOLUME_OBJD(volume);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index f3e2eef6f31..8f98f380854 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1879,8 +1879,9 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
else {
/* The expansion might have been changed elsewhere, so we still need to set it. */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED))
+ if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
UI_panel_set_expand_from_list_data(C, panel);
+ }
}
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
@@ -2055,8 +2056,9 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
else {
/* The expansion might have been changed elsewhere, so we still need to set it. */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED))
+ if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
UI_panel_set_expand_from_list_data(C, panel);
+ }
}
}
}
@@ -2115,8 +2117,9 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
else {
/* The expansion might have been changed elsewhere, so we still need to set it. */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED))
+ if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
UI_panel_set_expand_from_list_data(C, panel);
+ }
}
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
@@ -2193,8 +2196,9 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
else {
/* The expansion might have been changed elsewhere, so we still need to set it. */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED))
+ if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
UI_panel_set_expand_from_list_data(C, panel);
+ }
}
}
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index ca5e1921595..b8dbc5c279d 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1769,12 +1769,14 @@ static void vgroup_lock_all(Object *ob, int action, int mask)
switch (mask) {
case VGROUP_MASK_INVERT_UNSELECTED:
case VGROUP_MASK_SELECTED:
- if (!selected[i])
+ if (!selected[i]) {
continue;
+ }
break;
case VGROUP_MASK_UNSELECTED:
- if (selected[i])
+ if (selected[i]) {
continue;
+ }
break;
default:;
}
@@ -1789,12 +1791,14 @@ static void vgroup_lock_all(Object *ob, int action, int mask)
for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) {
switch (mask) {
case VGROUP_MASK_SELECTED:
- if (!selected[i])
+ if (!selected[i]) {
continue;
+ }
break;
case VGROUP_MASK_UNSELECTED:
- if (selected[i])
+ if (selected[i]) {
continue;
+ }
break;
default:;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 544c41a3a7b..2f42f3be50c 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -769,20 +769,23 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
}
case ID_HA: {
Hair *hair = (Hair *)id;
- if (outliner_animdata_test(hair->adt))
+ if (outliner_animdata_test(hair->adt)) {
outliner_add_element(soops, &te->subtree, hair, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_PT: {
PointCloud *pointcloud = (PointCloud *)id;
- if (outliner_animdata_test(pointcloud->adt))
+ if (outliner_animdata_test(pointcloud->adt)) {
outliner_add_element(soops, &te->subtree, pointcloud, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_VO: {
Volume *volume = (Volume *)id;
- if (outliner_animdata_test(volume->adt))
+ if (outliner_animdata_test(volume->adt)) {
outliner_add_element(soops, &te->subtree, volume, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_SIM: {
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 59087df16dd..b34c324bd91 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -96,8 +96,9 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
/* helpers */
#define WRITE_COMMA \
{ \
- if (!first) \
+ if (!first) { \
fprintf(f, ", "); \
+ } \
first = 0; \
} \
(void)0
@@ -118,10 +119,12 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
FILE *file_test = fopen(orgfile, "rb"); \
if (file_test) { \
fclose(file_test); \
- if (fp_org) \
+ if (fp_org) { \
fclose(fp_org); \
- if (fp_new) \
+ } \
+ if (fp_new) { \
fclose(fp_new); \
+ } \
if (remove(orgfile) != 0) { \
CLOG_ERROR(&LOG, "remove error (%s): \"%s\"", strerror(errno), orgfile); \
return -1; \
@@ -1080,21 +1083,26 @@ static char *rna_def_property_set_func(
if (prop->flag & PROP_ID_SELF_CHECK) {
rna_print_id_get(f, dp);
- fprintf(f, " if (id == value.data) return;\n\n");
+ fprintf(f, " if (id == value.data) {\n");
+ fprintf(f, " return;\n");
+ fprintf(f, " }\n");
}
if (prop->flag & PROP_ID_REFCOUNT) {
- fprintf(f, "\n if (data->%s)\n", dp->dnaname);
+ fprintf(f, "\n if (data->%s) {\n", dp->dnaname);
fprintf(f, " id_us_min((ID *)data->%s);\n", dp->dnaname);
- fprintf(f, " if (value.data)\n");
- fprintf(f, " id_us_plus((ID *)value.data);\n\n");
+ fprintf(f, " }\n");
+ fprintf(f, " if (value.data) {\n");
+ fprintf(f, " id_us_plus((ID *)value.data);\n");
+ fprintf(f, " }\n");
}
else {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
StructRNA *type = (pprop->type) ? rna_find_struct((const char *)pprop->type) : NULL;
if (type && (type->flag & STRUCT_ID)) {
- fprintf(f, " if (value.data)\n");
- fprintf(f, " id_lib_extern((ID *)value.data);\n\n");
+ fprintf(f, " if (value.data) {\n");
+ fprintf(f, " id_lib_extern((ID *)value.data);\n");
+ fprintf(f, " }\n");
}
}
@@ -1141,14 +1149,14 @@ static char *rna_def_property_set_func(
if (dp->dnaarraylength == 1) {
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
fprintf(f,
- " if (%svalues[i]) data->%s |= (",
+ " if (%svalues[i]) { data->%s |= (",
(dp->booleannegative) ? "!" : "",
dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, " << i);\n");
- fprintf(f, " else data->%s &= ~(", dp->dnaname);
+ fprintf(f, " << i); }\n");
+ fprintf(f, " else { data->%s &= ~(", dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, " << i);\n");
+ fprintf(f, " << i); }\n");
}
else {
fprintf(
@@ -1159,14 +1167,14 @@ static char *rna_def_property_set_func(
else {
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
fprintf(f,
- " if (%svalues[i]) data->%s[i] |= ",
+ " if (%svalues[i]) { data->%s[i] |= ",
(dp->booleannegative) ? "!" : "",
dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
- fprintf(f, " else data->%s[i] &= ~", dp->dnaname);
+ fprintf(f, "; }\n");
+ fprintf(f, " else { data->%s[i] &= ~", dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
+ fprintf(f, "; }\n");
}
else if (rna_color_quantize(prop, dp)) {
fprintf(
@@ -1215,13 +1223,15 @@ static char *rna_def_property_set_func(
else {
rna_print_data_get(f, dp);
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(
- f, " if (%svalue) data->%s |= ", (dp->booleannegative) ? "!" : "", dp->dnaname);
+ fprintf(f,
+ " if (%svalue) { data->%s |= ",
+ (dp->booleannegative) ? "!" : "",
+ dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
- fprintf(f, " else data->%s &= ~", dp->dnaname);
+ fprintf(f, "; }\n");
+ fprintf(f, " else { data->%s &= ~", dp->dnaname);
rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
+ fprintf(f, "; }\n");
}
else if (prop->type == PROP_ENUM && dp->enumbitflags) {
fprintf(f, " data->%s &= ~", dp->dnaname);
@@ -1278,7 +1288,7 @@ static char *rna_def_property_length_func(
else {
rna_print_data_get(f, dp);
if (!(prop->flag & PROP_NEVER_NULL)) {
- fprintf(f, " if (data->%s == NULL) return 0;\n", dp->dnaname);
+ fprintf(f, " if (data->%s == NULL) { return 0; }\n", dp->dnaname);
}
fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
}
@@ -1393,8 +1403,9 @@ static char *rna_def_property_begin_func(
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
- fprintf(f, "\n if (iter->valid)\n");
- fprintf(f, " iter->ptr = %s(iter);\n", getfunc);
+ fprintf(f, "\n if (iter->valid) {\n");
+ fprintf(f, " iter->ptr = %s(iter);", getfunc);
+ fprintf(f, "\n }\n");
fprintf(f, "}\n\n");
@@ -1479,14 +1490,15 @@ static char *rna_def_property_lookup_int_func(FILE *f,
fprintf(f, " found = (index == -1 && iter.valid);\n");
fprintf(f, " }\n");
fprintf(f, " else {\n");
- fprintf(f, " while (index-- > 0 && internal->link)\n");
+ fprintf(f, " while (index-- > 0 && internal->link) {\n");
fprintf(f, " internal->link = internal->link->next;\n");
+ fprintf(f, " }\n");
fprintf(f, " found = (index == -1 && internal->link);\n");
fprintf(f, " }\n");
}
fprintf(f,
- " if (found) *r_ptr = %s_%s_get(&iter);\n",
+ " if (found) { *r_ptr = %s_%s_get(&iter); }\n",
srna->identifier,
rna_safe_id(prop->identifier));
fprintf(f, " }\n\n");
@@ -1672,8 +1684,9 @@ static char *rna_def_property_next_func(FILE *f,
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
- fprintf(f, "\n if (iter->valid)\n");
- fprintf(f, " iter->ptr = %s(iter);\n", getfunc);
+ fprintf(f, "\n if (iter->valid) {\n");
+ fprintf(f, " iter->ptr = %s(iter);", getfunc);
+ fprintf(f, "\n }\n");
fprintf(f, "}\n\n");