Cleanup: style, use braces for editor/spaces
authorCampbell Barton <ideasman42@gmail.com>
Tue, 26 Mar 2019 10:16:47 +0000 (21:16 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 26 Mar 2019 10:16:47 +0000 (21:16 +1100)
66 files changed:
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_buttons/buttons_texture.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_console/console_draw.c
source/blender/editors/space_console/console_ops.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_edit.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_info/info_ops.c
source/blender/editors/space_info/info_report.c
source/blender/editors/space_info/info_stats.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_info/textview.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_add.c
source/blender/editors/space_node/node_buttons.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_group.c
source/blender/editors/space_node/node_relationships.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_templates.c
source/blender/editors/space_node/node_toolbar.c
source/blender/editors/space_node/node_view.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_dragdrop.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_outliner/outliner_utils.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_buttons.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_modifier.c
source/blender/editors/space_sequencer/sequencer_scopes.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/editors/space_sequencer/sequencer_view.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_statusbar/space_statusbar.c
source/blender/editors/space_topbar/space_topbar.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_camera_control.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_gizmo_armature.c
source/blender/editors/space_view3d/view3d_gizmo_camera.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_project.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/editors/space_view3d/view3d_utils.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/space_view3d/view3d_walk.c

index 152442f..0579e20 100644 (file)
@@ -93,8 +93,9 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
        for (a = 0; a < path->len; a++) {
                ptr = &path->ptr[a];
 
-               if (RNA_struct_is_a(ptr->type, type))
+               if (RNA_struct_is_a(ptr->type, type)) {
                        return ptr;
+               }
        }
 
        return NULL;
@@ -221,16 +222,36 @@ static int buttons_context_path_data(ButsContextPath *path, int type)
        PointerRNA *ptr = &path->ptr[path->len - 1];
 
        /* if we already have a data, we're done */
-       if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1;
-       else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) return 1;
+       if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) {
+               return 1;
+       }
+       else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) {
+               return 1;
+       }
        /* try to get an object in the path, no pinning supported here */
        else if (buttons_context_path_object(path)) {
                ob = path->ptr[path->len - 1].data;
@@ -254,8 +275,9 @@ static int buttons_context_path_modifier(ButsContextPath *path)
        if (buttons_context_path_object(path)) {
                ob = path->ptr[path->len - 1].data;
 
-               if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL))
+               if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) {
                        return 1;
+               }
        }
 
        return 0;
@@ -268,8 +290,9 @@ static int buttons_context_path_shaderfx(ButsContextPath *path)
        if (buttons_context_path_object(path)) {
                ob = path->ptr[path->len - 1].data;
 
-               if (ob && ELEM(ob->type, OB_GPENCIL))
+               if (ob && ELEM(ob->type, OB_GPENCIL)) {
                        return 1;
+               }
        }
 
        return 0;
@@ -429,27 +452,34 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path
        PointerRNA *ptr = &path->ptr[path->len - 1];
        ID *id;
 
-       if (!ct)
+       if (!ct) {
                return 0;
+       }
 
        /* if we already have a (pinned) texture, we're done */
-       if (RNA_struct_is_a(ptr->type, &RNA_Texture))
+       if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
                return 1;
+       }
 
-       if (!ct->user)
+       if (!ct->user) {
                return 0;
+       }
 
        id = ct->user->id;
 
        if (id) {
-               if (GS(id->name) == ID_BR)
+               if (GS(id->name) == ID_BR) {
                        buttons_context_path_brush(C, path);
-               else if (GS(id->name) == ID_PA)
+               }
+               else if (GS(id->name) == ID_PA) {
                        buttons_context_path_particle(path);
-               else if (GS(id->name) == ID_OB)
+               }
+               else if (GS(id->name) == ID_OB) {
                        buttons_context_path_object(path);
-               else if (GS(id->name) == ID_LS)
+               }
+               else if (GS(id->name) == ID_LS) {
                        buttons_context_path_linestyle(path, CTX_wm_window(C));
+               }
        }
 
        if (ct->texture) {
@@ -568,8 +598,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
                        break;
                case BCONTEXT_BONE:
                        found = buttons_context_path_bone(path);
-                       if (!found)
+                       if (!found) {
                                found = buttons_context_path_data(path, OB_ARMATURE);
+                       }
                        break;
                case BCONTEXT_BONE_CONSTRAINT:
                        found = buttons_context_path_pose_bone(path);
@@ -588,10 +619,12 @@ static int buttons_shading_context(const bContext *C, int mainb)
        ViewLayer *view_layer = WM_window_get_active_view_layer(window);
        Object *ob = OBACT(view_layer);
 
-       if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
+       if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) {
                return 1;
-       if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
+       }
+       if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) {
                return 1;
+       }
 
        return 0;
 }
@@ -602,12 +635,15 @@ static int buttons_shading_new_context(const bContext *C, int flag)
        ViewLayer *view_layer = WM_window_get_active_view_layer(window);
        Object *ob = OBACT(view_layer);
 
-       if (flag & (1 << BCONTEXT_MATERIAL))
+       if (flag & (1 << BCONTEXT_MATERIAL)) {
                return BCONTEXT_MATERIAL;
-       else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA)))
+       }
+       else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) {
                return BCONTEXT_DATA;
-       else if (flag & (1 << BCONTEXT_WORLD))
+       }
+       else if (flag & (1 << BCONTEXT_WORLD)) {
                return BCONTEXT_WORLD;
+       }
 
        return BCONTEXT_RENDER;
 }
@@ -618,8 +654,9 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
        PointerRNA *ptr;
        int a, pflag = 0, flag = 0;
 
-       if (!sbuts->path)
+       if (!sbuts->path) {
                sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
+       }
 
        path = sbuts->path;
 
@@ -639,10 +676,12 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
                                ptr = &path->ptr[path->len - 1];
 
                                if (ptr->type) {
-                                       if (RNA_struct_is_a(ptr->type, &RNA_Light))
+                                       if (RNA_struct_is_a(ptr->type, &RNA_Light)) {
                                                sbuts->dataicon = ICON_OUTLINER_DATA_LIGHT;
-                                       else
+                                       }
+                                       else {
                                                sbuts->dataicon = RNA_struct_ui_icon(ptr->type);
+                                       }
                                }
                                else {
                                        sbuts->dataicon = ICON_EMPTY_DATA;
@@ -678,16 +717,20 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
        buttons_context_path(C, path, sbuts->mainb, pflag);
 
        if (!(flag & (1 << sbuts->mainb))) {
-               if (flag & (1 << BCONTEXT_OBJECT))
+               if (flag & (1 << BCONTEXT_OBJECT)) {
                        sbuts->mainb = BCONTEXT_OBJECT;
-               else
+               }
+               else {
                        sbuts->mainb = BCONTEXT_SCENE;
+               }
        }
 
-       if (buttons_shading_context(C, sbuts->mainb))
+       if (buttons_shading_context(C, sbuts->mainb)) {
                sbuts->flag |= SB_SHADING_CONTEXT;
-       else
+       }
+       else {
                sbuts->flag &= ~SB_SHADING_CONTEXT;
+       }
 
        sbuts->pathflag = flag;
 }
@@ -708,17 +751,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
        SpaceProperties *sbuts = CTX_wm_space_properties(C);
        ButsContextPath *path = sbuts ? sbuts->path : NULL;
 
-       if (!path)
+       if (!path) {
                return 0;
+       }
 
        /* here we handle context, getting data from precomputed path */
        if (CTX_data_dir(member)) {
                /* in case of new shading system we skip texture_slot, complex python
                 * UI script logic depends on checking if this is available */
-               if (sbuts->texuser)
+               if (sbuts->texuser) {
                        CTX_data_dir_set(result, buttons_context_dir + 1);
-               else
+               }
+               else {
                        CTX_data_dir_set(result, buttons_context_dir);
+               }
                return 1;
        }
        else if (CTX_data_equals(member, "scene")) {
@@ -792,7 +838,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                        if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) {
                                /* a valid actcol isn't ensured [#27526] */
                                int matnr = ob->actcol - 1;
-                               if (matnr < 0) matnr = 0;
+                               if (matnr < 0) {
+                                       matnr = 0;
+                               }
                                CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]);
                        }
                }
@@ -802,8 +850,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
        else if (CTX_data_equals(member, "texture_user")) {
                ButsContextTexture *ct = sbuts->texuser;
 
-               if (!ct)
+               if (!ct) {
                        return -1;
+               }
 
                if (ct->user && ct->user->ptr.data) {
                        ButsTextureUser *user = ct->user;
@@ -815,8 +864,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
        else if (CTX_data_equals(member, "texture_user_property")) {
                ButsContextTexture *ct = sbuts->texuser;
 
-               if (!ct)
+               if (!ct) {
                        return -1;
+               }
 
                if (ct->user && ct->user->ptr.data) {
                        ButsTextureUser *user = ct->user;
@@ -845,8 +895,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
                        ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
 
-                       if (part)
+                       if (part) {
                                CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
+                       }
                }
                else if (ct) {
                        return 0;  /* new shading system */
@@ -854,8 +905,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
                        FreestyleLineStyle *ls = ptr->data;
 
-                       if (ls)
+                       if (ls) {
                                CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]);
+                       }
                }
 
                return 1;
@@ -877,10 +929,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                return 1;
        }
        else if (CTX_data_equals(member, "particle_system_editable")) {
-               if (PE_poll((bContext *)C))
+               if (PE_poll((bContext *)C)) {
                        set_pointer_type(path, result, &RNA_ParticleSystem);
-               else
+               }
+               else {
                        CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
+               }
                return 1;
        }
        else if (CTX_data_equals(member, "particle_settings")) {
@@ -993,8 +1047,9 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
        if (sbuts->flag & SB_PIN_CONTEXT) {
                sbuts->pinid = buttons_context_id_path(C);
        }
-       else
+       else {
                sbuts->pinid = NULL;
+       }
 
        ED_area_tag_redraw(CTX_wm_area(C));
 }
@@ -1011,8 +1066,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
        int a, icon;
        bool first = true;
 
-       if (!path)
+       if (!path) {
                return;
+       }
 
        row = uiLayoutRow(layout, true);
        uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
@@ -1044,8 +1100,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
                        if (name) {
                                uiItemLDrag(row, ptr, name, icon);
 
-                               if (name != namebuf)
+                               if (name != namebuf) {
                                        MEM_freeN(name);
+                               }
                        }
                        else {
                                uiItemL(row, "", icon);
index 7cec9c0..3ae88f9 100644 (file)
@@ -99,8 +99,9 @@ static int file_browse_exec(bContext *C, wmOperator *op)
        char *str, path[FILE_MAX];
        const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
 
-       if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL)
+       if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) {
                return OPERATOR_CANCELLED;
+       }
 
        str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0);
 
@@ -127,7 +128,9 @@ static int file_browse_exec(bContext *C, wmOperator *op)
                }
                else {
                        char * const lslash = (char *)BLI_last_slash(str);
-                       if (lslash) lslash[1] = '\0';
+                       if (lslash) {
+                               lslash[1] = '\0';
+                       }
                }
        }
 
@@ -176,8 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
        UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo);
 
-       if (!prop)
+       if (!prop) {
                return OPERATOR_CANCELLED;
+       }
 
        str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
 
@@ -189,8 +193,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
                if (event->alt) {
                        char *lslash = (char *)BLI_last_slash(str);
-                       if (lslash)
+                       if (lslash) {
                                *lslash = '\0';
+                       }
                }
 
 
index 067e0f5..7c1355b 100644 (file)
@@ -172,14 +172,18 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
 
        /* get data from context */
        if (pinid) {
-               if (GS(pinid->name) == ID_SCE)
+               if (GS(pinid->name) == ID_SCE) {
                        scene = (Scene *)pinid;
-               else if (GS(pinid->name) == ID_OB)
+               }
+               else if (GS(pinid->name) == ID_OB) {
                        ob = (Object *)pinid;
-               else if (GS(pinid->name) == ID_BR)
+               }
+               else if (GS(pinid->name) == ID_BR) {
                        brush = (Brush *)pinid;
-               else if (GS(pinid->name) == ID_LS)
+               }
+               else if (GS(pinid->name) == ID_LS) {
                        linestyle = (FreestyleLineStyle *)pinid;
+               }
        }
 
        if (!scene) {
@@ -201,8 +205,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
        /* fill users */
        BLI_listbase_clear(users);
 
-       if (linestyle && !limited_mode)
+       if (linestyle && !limited_mode) {
                buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style"));
+       }
 
        if (ob) {
                ParticleSystem *psys = psys_get_current(ob);
@@ -290,8 +295,9 @@ void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts)
        }
        else {
                /* set one user as active based on active index */
-               if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1))
+               if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) {
                        ct->index = 0;
+               }
 
                ct->user = BLI_findlink(&ct->users, ct->index);
                ct->texture = NULL;
@@ -335,8 +341,9 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
        PointerRNA texptr;
        Tex *tex;
 
-       if (!ct)
+       if (!ct) {
                return;
+       }
 
        /* set user as active */
        if (user->node) {
@@ -355,13 +362,16 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
                        ParticleSettings *part = user->ptr.id.data;
                        int a;
 
-                       for (a = 0; a < MAX_MTEX; a++)
-                               if (user->ptr.data == part->mtex[a])
+                       for (a = 0; a < MAX_MTEX; a++) {
+                               if (user->ptr.data == part->mtex[a]) {
                                        part->texact = a;
+                               }
+                       }
                }
 
-               if (sbuts && tex)
+               if (sbuts && tex) {
                        sbuts->preview = 1;
+               }
        }
 
        ct->user = user;
@@ -393,13 +403,16 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS
                        PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop);
                        Tex *tex = texptr.data;
 
-                       if (tex)
+                       if (tex) {
                                BLI_snprintf(name, UI_MAX_NAME_STR, "  %s - %s", user->name, tex->id.name + 2);
-                       else
+                       }
+                       else {
                                BLI_snprintf(name, UI_MAX_NAME_STR, "  %s", user->name);
+                       }
                }
-               else
+               else {
                        BLI_snprintf(name, UI_MAX_NAME_STR, "  %s", user->name);
+               }
 
                but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
                                       NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -423,8 +436,9 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C)
        ButsTextureUser *user;
        char name[UI_MAX_NAME_STR];
 
-       if (!ct)
+       if (!ct) {
                return;
+       }
 
        /* get current user */
        user = ct->user;
@@ -460,12 +474,15 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p)
        ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL;
        ButsTextureUser *user;
 
-       if (!ct)
+       if (!ct) {
                return;
+       }
 
-       for (user = ct->users.first; user; user = user->next)
-               if (user->ptr.data == data_p && user->prop == prop_p)
+       for (user = ct->users.first; user; user = user->next) {
+               if (user->ptr.data == data_p && user->prop == prop_p) {
                        break;
+               }
+       }
 
        if (user) {
                /* select texture */
@@ -489,13 +506,16 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope
        ButsTextureUser *user;
 
        /* only show button in other tabs in properties editor */
-       if (!ct || sbuts->mainb == BCONTEXT_TEXTURE)
+       if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) {
                return;
+       }
 
        /* find corresponding texture user */
-       for (user = ct->users.first; user; user = user->next)
-               if (user->ptr.data == ptr->data && user->prop == prop)
+       for (user = ct->users.first; user; user = user->next) {
+               if (user->ptr.data == ptr->data && user->prop == prop) {
                        break;
+               }
+       }
 
        /* draw button */
        if (user) {
index 609ef86..3bf2d63 100644 (file)
@@ -97,8 +97,9 @@ static void buttons_free(SpaceLink *sl)
 {
        SpaceProperties *sbuts = (SpaceProperties *) sl;
 
-       if (sbuts->path)
+       if (sbuts->path) {
                MEM_freeN(sbuts->path);
+       }
 
        if (sbuts->texuser) {
                ButsContextTexture *ct = sbuts->texuser;
@@ -451,8 +452,9 @@ static void buttons_area_redraw(ScrArea *sa, short buttons)
        SpaceProperties *sbuts = sa->spacedata.first;
 
        /* if the area's current button set is equal to the one to redraw */
-       if (sbuts->mainb == buttons)
+       if (sbuts->mainb == buttons) {
                ED_area_tag_redraw(sa);
+       }
 }
 
 /* reused! */
@@ -510,10 +512,12 @@ static void buttons_area_listener(
                                        buttons_area_redraw(sa, BCONTEXT_DATA);
                                        break;
                                case ND_MODIFIER:
-                                       if (wmn->action == NA_RENAME)
+                                       if (wmn->action == NA_RENAME) {
                                                ED_area_tag_redraw(sa);
-                                       else
+                                       }
+                                       else {
                                                buttons_area_redraw(sa, BCONTEXT_MODIFIER);
+                                       }
                                        buttons_area_redraw(sa, BCONTEXT_PHYSICS);
                                        break;
                                case ND_CONSTRAINT:
@@ -521,8 +525,9 @@ static void buttons_area_listener(
                                        buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT);
                                        break;
                                case ND_PARTICLE:
-                                       if (wmn->action == NA_EDITED)
+                                       if (wmn->action == NA_EDITED) {
                                                buttons_area_redraw(sa, BCONTEXT_PARTICLE);
+                                       }
                                        sbuts->preview = 1;
                                        break;
                                case ND_DRAW:
@@ -589,26 +594,30 @@ static void buttons_area_listener(
                        }
                        break;
                case NC_SPACE:
-                       if (wmn->data == ND_SPACE_PROPERTIES)
+                       if (wmn->data == ND_SPACE_PROPERTIES) {
                                ED_area_tag_redraw(sa);
+                       }
                        break;
                case NC_ID:
-                       if (wmn->action == NA_RENAME)
+                       if (wmn->action == NA_RENAME) {
                                ED_area_tag_redraw(sa);
+                       }
                        break;
                case NC_ANIMATION:
                        switch (wmn->data) {
                                case ND_KEYFRAME:
-                                       if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+                                       if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
                                                ED_area_tag_redraw(sa);
+                                       }
                                        break;
                        }
                        break;
                case NC_GPENCIL:
                        switch (wmn->data) {
                                case ND_DATA:
-                                       if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+                                       if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
                                                ED_area_tag_redraw(sa);
+                                       }
                                        break;
                        }
                        break;
@@ -616,8 +625,9 @@ static void buttons_area_listener(
                        if (wmn->action == NA_SELECTED) {
                                ED_area_tag_redraw(sa);
                                /* new active node, update texture preview */
-                               if (sbuts->mainb == BCONTEXT_TEXTURE)
+                               if (sbuts->mainb == BCONTEXT_TEXTURE) {
                                        sbuts->preview = 1;
+                               }
                        }
                        break;
                /* Listener for preview render, when doing an global undo. */
@@ -635,8 +645,9 @@ static void buttons_area_listener(
 #endif
        }
 
-       if (wmn->data == ND_KEYS)
+       if (wmn->data == ND_KEYS) {
                ED_area_tag_redraw(sa);
+       }
 }
 
 static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
index b7e4133..042fb36 100644 (file)
@@ -132,8 +132,9 @@ static void console_cursor_wrap_offset(const char *str, int width, int *row, int
                        *column = 0;
                }
 
-               if (end && str >= end)
+               if (end && str >= end) {
                        break;
+               }
 
                *column += col;
        }
index 46d22df..d448933 100644 (file)
@@ -87,10 +87,13 @@ static void console_scrollback_limit(SpaceConsole *sc)
 {
        int tot;
 
-       if (U.scrollback < 32) U.scrollback = 256;  // XXX - save in user defaults
+       if (U.scrollback < 32) {
+               U.scrollback = 256;  // XXX - save in user defaults
+       }
 
-       for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--)
+       for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) {
                console_scrollback_free(sc, sc->scrollback.first);
+       }
 }
 
 static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
@@ -98,11 +101,13 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons
        ConsoleLine *cl;
 
        for (cl = sc->history.last; cl; cl = cl->prev) {
-               if (cl == cl_ignore)
+               if (cl == cl_ignore) {
                        continue;
+               }
 
-               if (STREQ(str, cl->line))
+               if (STREQ(str, cl->line)) {
                        return cl;
+               }
        }
 
        return NULL;
@@ -113,9 +118,15 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
 {
        int cursor_new;
 
-       if      (cursor < 0) cursor_new = 0;
-       else if (cursor > cl->len) cursor_new = cl->len;
-       else cursor_new = cursor;
+       if (cursor < 0) {
+               cursor_new = 0;
+       }
+       else if (cursor > cl->len) {
+               cursor_new = cl->len;
+       }
+       else {
+               cursor_new = cursor;
+       }
 
        if (cursor_new == cl->cursor) {
                return false;
@@ -184,8 +195,12 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
 static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own)
 {
        ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
-       if (own) ci->line = str;
-       else ci->line = BLI_strdup(str);
+       if (own) {
+               ci->line = str;
+       }
+       else {
+               ci->line = BLI_strdup(str);
+       }
 
        ci->len = ci->len_alloc = strlen(str);
 
@@ -207,8 +222,9 @@ ConsoleLine *console_history_verify(const bContext *C)
 {
        SpaceConsole *sc = CTX_wm_space_console(C);
        ConsoleLine *ci = sc->history.last;
-       if (ci == NULL)
+       if (ci == NULL) {
                ci = console_history_add(sc, NULL);
+       }
 
        return ci;
 }
@@ -242,8 +258,9 @@ static int console_line_insert(ConsoleLine *ci, char *str)
                len--;
        }
 
-       if (len == 0)
+       if (len == 0) {
                return 0;
+       }
 
        console_line_verify_length(ci, len + ci->len);
 
@@ -480,8 +497,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
        int len;
 
        for (spaces = 0; spaces < ci->len; spaces++) {
-               if (ci->line[spaces] != ' ')
+               if (ci->line[spaces] != ' ') {
                        break;
+               }
        }
 
        len = TAB_LENGTH - spaces % TAB_LENGTH;
@@ -524,16 +542,19 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
        int len;
 
        for (spaces = 0; spaces < ci->len; spaces++) {
-               if (ci->line[spaces] != ' ')
+               if (ci->line[spaces] != ' ') {
                        break;
+               }
        }
 
-       if (spaces == 0)
+       if (spaces == 0) {
                return OPERATOR_CANCELLED;
+       }
 
        len = spaces % TAB_LENGTH;
-       if (len == 0)
+       if (len == 0) {
                len = TAB_LENGTH;
+       }
 
        console_line_verify_length(ci, ci->len - len);
 
@@ -701,13 +722,15 @@ static int console_clear_exec(bContext *C, wmOperator *op)
        /*ConsoleLine *ci = */ console_history_verify(C);
 
        if (scrollback) { /* last item in mistory */
-               while (sc->scrollback.first)
+               while (sc->scrollback.first) {
                        console_scrollback_free(sc, sc->scrollback.first);
+               }
        }
 
        if (history) {
-               while (sc->history.first)
+               while (sc->history.first) {
                        console_history_free(sc, sc->history.first);
+               }
                console_history_verify(C);
        }
 
@@ -751,8 +774,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
        if (ci->prev) {
                ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
 
-               if (STREQ(ci->line, ci_prev->line))
+               if (STREQ(ci->line, ci_prev->line)) {
                        console_history_free(sc, ci_prev);
+               }
        }
 
        if (reverse) { /* last item in history */
@@ -768,8 +792,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
 
        {   /* add a duplicate of the new arg and remove all other instances */
                ConsoleLine *cl;
-               while ((cl = console_history_find(sc, ci->line, ci)))
+               while ((cl = console_history_find(sc, ci->line, ci))) {
                        console_history_free(sc, cl);
+               }
 
                console_history_add(sc, (ConsoleLine *)sc->history.last);
        }
@@ -818,8 +843,9 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
        if (rem_dupes) {
                ConsoleLine *cl;
 
-               while ((cl = console_history_find(sc, ci->line, ci)))
+               while ((cl = console_history_find(sc, ci->line, ci))) {
                        console_history_free(sc, cl);
+               }
 
                if (STREQ(str, ci->line)) {
                        MEM_freeN(str);
@@ -928,8 +954,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
 
        ConsoleLine cl_dummy = {NULL};
 
-       if (sc->sel_start == sc->sel_end)
+       if (sc->sel_start == sc->sel_end) {
                return OPERATOR_CANCELLED;
+       }
 
        console_scrollback_prompt_begin(sc, &cl_dummy);
 
@@ -952,8 +979,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
                        int sta = max_ii(sel[0], 0);
                        int end = min_ii(sel[1], cl->len);
 
-                       if (BLI_dynstr_get_len(buf_dyn))
+                       if (BLI_dynstr_get_len(buf_dyn)) {
                                BLI_dynstr_append(buf_dyn, "\n");
+                       }
 
                        BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta);
                }
@@ -998,8 +1026,9 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op))
        char *buf_str = WM_clipboard_text_get(false, &buf_len);
        char *buf_step, *buf_next;
 
-       if (buf_str == NULL)
+       if (buf_str == NULL) {
                return OPERATOR_CANCELLED;
+       }
 
        buf_step = buf_str;
 
index 65f1fe3..5d4623e 100644 (file)
@@ -88,11 +88,13 @@ static void console_free(SpaceLink *sl)
 {
        SpaceConsole *sc = (SpaceConsole *) sl;
 
-       while (sc->scrollback.first)
+       while (sc->scrollback.first) {
                console_scrollback_free(sc, sc->scrollback.first);
+       }
 
-       while (sc->history.first)
+       while (sc->history.first) {
                console_history_free(sc, sc->history.first);
+       }
 }
 
 
@@ -208,8 +210,9 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
        View2D *v2d = &ar->v2d;
        View2DScrollers *scrollers;
 
-       if (BLI_listbase_is_empty(&sc->scrollback))
+       if (BLI_listbase_is_empty(&sc->scrollback)) {
                WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
+       }
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
index b77c087..47b3f99 100644 (file)
@@ -69,8 +69,9 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
        size_t ofs = 0;
 
        str[0] = 0;
-       if (ima == NULL)
+       if (ima == NULL) {
                return;
+       }
 
        if (ibuf == NULL) {
                ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Can't Load Image"), len - ofs);
@@ -78,9 +79,10 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
        else {
                if (ima->source == IMA_SRC_MOVIE) {
                        ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Movie"), len - ofs);
-                       if (BKE_image_has_anim(ima))
+                       if (BKE_image_has_anim(ima)) {
                                ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_(" %d frs"),
                                                    IMB_anim_get_duration(((ImageAnim *)ima->anims.first)->anim, IMB_TC_RECORD_RUN));
+                       }
                }
                else {
                        ofs += BLI_strncpy_rlen(str, IFACE_("Image"), len - ofs);
@@ -92,26 +94,33 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
                        if (ibuf->channels != 4) {
                                ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_("%d float channel(s)"), ibuf->channels);
                        }
-                       else if (ibuf->planes == R_IMF_PLANES_RGBA)
+                       else if (ibuf->planes == R_IMF_PLANES_RGBA) {
                                ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA float"), len - ofs);
-                       else
+                       }
+                       else {
                                ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB float"), len - ofs);
+                       }
                }
                else {
-                       if (ibuf->planes == R_IMF_PLANES_RGBA)
+                       if (ibuf->planes == R_IMF_PLANES_RGBA) {
                                ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA byte"), len - ofs);
-                       else
+                       }
+                       else {
                                ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB byte"), len - ofs);
+                       }
                }
-               if (ibuf->zbuf || ibuf->zbuf_float)
+               if (ibuf->zbuf || ibuf->zbuf_float) {
                        ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" + Z"), len - ofs);
+               }
 
                if (ima->source == IMA_SRC_SEQUENCE) {
                        const char *file = BLI_last_slash(ibuf->name);
-                       if (file == NULL)
+                       if (file == NULL) {
                                file = ibuf->name;
-                       else
+                       }
+                       else {
                                file++;
+                       }
                        ofs += BLI_snprintf(str + ofs, len - ofs, ", %s", file);
                }
        }
@@ -129,11 +138,15 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
 {
        bNode *node;
 
-       if (ntree)
-               for (node = ntree->nodes.first; node; node = node->next)
-                       if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
-                               if (node->flag & NODE_DO_OUTPUT)
+       if (ntree) {
+               for (node = ntree->nodes.first; node; node = node->next) {
+                       if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+                               if (node->flag & NODE_DO_OUTPUT) {
                                        return node->storage;
+                               }
+                       }
+               }
+       }
        return NULL;
 }
 
@@ -543,8 +556,9 @@ static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_p
        else if (direction == 1) {
                int tot = BLI_listbase_count(&rr->layers);
 
-               if (RE_HasCombinedLayer(rr))
+               if (RE_HasCombinedLayer(rr)) {
                        tot++;  /* fake compo/sequencer layer */
+               }
 
                if (iuser->layer < tot - 1) {
                        iuser->layer++;
@@ -835,8 +849,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 
        void *lock;
 
-       if (!ptr->data)
+       if (!ptr->data) {
                return;
+       }
 
        prop = RNA_struct_find_property(ptr, propname);
        if (!prop) {
@@ -921,10 +936,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 
                        if (ima->source != IMA_SRC_GENERATED) {
                                row = uiLayoutRow(layout, true);
-                               if (BKE_image_has_packedfile(ima))
+                               if (BKE_image_has_packedfile(ima)) {
                                        uiItemO(row, "", ICON_PACKAGE, "image.unpack");
-                               else
+                               }
+                               else {
                                        uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
+                               }
 
                                row = uiLayoutRow(row, true);
                                uiLayoutSetEnabled(row, BKE_image_has_packedfile(ima) == false);
@@ -1200,8 +1217,9 @@ void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA
 {
        ImageFormatData *imf = imfptr->data;
 
-       if (ptr == NULL)
+       if (ptr == NULL) {
                return;
+       }
 
        uiItemR(layout, ptr, "use_multiview", 0, NULL, ICON_NONE);
 
@@ -1247,8 +1265,9 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
        char str[MAX_IMAGE_INFO_LEN];
        void *lock;
 
-       if (!ima || !iuser)
+       if (!ima || !iuser) {
                return;
+       }
 
        ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
 
@@ -1297,8 +1316,9 @@ static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = image_has_buttons_region(sa);
 
-       if (ar)
+       if (ar) {
                ED_region_toggle_hidden(C, ar);
+       }
 
        return OPERATOR_FINISHED;
 }
@@ -1321,8 +1341,9 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = image_has_tools_region(sa);
 
-       if (ar)
+       if (ar) {
                ED_region_toggle_hidden(C, ar);
+       }
 
        return OPERATOR_FINISHED;
 }
index e3fd363..ca0f9bd 100644 (file)
@@ -282,15 +282,19 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
                        float rgba[4];
 
                        copy_v3_v3(rgba, linearcol);
-                       if (channels == 3)
+                       if (channels == 3) {
                                rgba[3] = 1.0f;
-                       else
+                       }
+                       else {
                                rgba[3] = linearcol[3];
+                       }
 
-                       if (use_default_view)
+                       if (use_default_view) {
                                IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings);
-                       else
+                       }
+                       else {
                                IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings);
+                       }
 
                        SNPRINTF(str, "  |  CM  R:%-.4f  G:%-.4f  B:%-.4f", rgba[0], rgba[1], rgba[2]);
                        BLF_position(blf_mono_font, dx, dy, 0);
@@ -325,10 +329,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
        }
 
        if (color_manage) {
-               if (use_default_view)
+               if (use_default_view) {
                        IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings);
-               else
+               }
+               else {
                        IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings);
+               }
        }
        else {
                copy_v4_v4(finalcol, col);
@@ -471,10 +477,12 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
 
        rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp");
        for (a = rectx * recty - 1; a >= 0; a--) {
-               if (rect_float[a] > clip_end)
+               if (rect_float[a] > clip_end) {
                        rectf[a] = 0.0f;
-               else if (rect_float[a] < bias)
+               }
+               else if (rect_float[a] < bias) {
                        rectf[a] = 1.0f;
+               }
                else {
                        rectf[a] = 1.0f - (rect_float[a] - bias) * scale;
                        rectf[a] *= rectf[a];
@@ -498,12 +506,15 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
 
        /* this part is generic image display */
        if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
-               if (ibuf->zbuf)
+               if (ibuf->zbuf) {
                        sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf, zoomx, zoomy);
-               else if (ibuf->zbuf_float)
+               }
+               else if (ibuf->zbuf_float) {
                        sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float, zoomx, zoomy);
-               else if (ibuf->channels == 1)
+               }
+               else if (ibuf->channels == 1) {
                        sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float, zoomx, zoomy);
+               }
        }
        else {
                int clip_max_x, clip_max_y;
@@ -531,14 +542,18 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
                        ColorManagedViewSettings *view_settings;
                        ColorManagedDisplaySettings *display_settings;
 
-                       if (sima->flag & SI_SHOW_R)
+                       if (sima->flag & SI_SHOW_R) {
                                shuffle[0] = 1.0f;
-                       else if (sima->flag & SI_SHOW_G)
+                       }
+                       else if (sima->flag & SI_SHOW_G) {
                                shuffle[1] = 1.0f;
-                       else if (sima->flag & SI_SHOW_B)
+                       }
+                       else if (sima->flag & SI_SHOW_B) {
                                shuffle[2] = 1.0f;
-                       else if (sima->flag & SI_SHOW_ALPHA)
+                       }
+                       else if (sima->flag & SI_SHOW_ALPHA) {
                                shuffle[3] = 1.0f;
+                       }
 
                        IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
                        GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle);
@@ -554,8 +569,9 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
                        IMB_display_buffer_release(cache_handle);
                }
 
-               if (sima->flag & SI_USE_ALPHA)
+               if (sima->flag & SI_USE_ALPHA) {
                        GPU_blend(false);
+               }
        }
 }
 
@@ -573,8 +589,9 @@ static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, AReg
                        draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
 
                        /* only draw until running out of time */
-                       if ((PIL_check_seconds_timer() - time_current) > 0.25)
+                       if ((PIL_check_seconds_timer() - time_current) > 0.25) {
                                return;
+                       }
                }
        }
 }
@@ -715,11 +732,13 @@ void draw_image_main(const bContext *C, ARegion *ar)
        }
 
        if (show_stereo3d) {
-               if (show_multilayer)
+               if (show_multilayer) {
                        /* update multiindex and pass for the current eye */
                        BKE_image_multilayer_index(ima->rr, &sima->iuser);
-               else
+               }
+               else {
                        BKE_image_multiview_index(ima, &sima->iuser);
+               }
        }
 
        ibuf = ED_space_image_acquire_buffer(sima, &lock);
@@ -729,10 +748,12 @@ void draw_image_main(const bContext *C, ARegion *ar)
                ED_region_grid_draw(ar, zoomx, zoomy);
        }
        else {
-               if (sima->flag & SI_DRAW_TILE)
+               if (sima->flag & SI_DRAW_TILE) {
                        draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy);
-               else
+               }
+               else {
                        draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+               }
 
                if (sima->flag & SI_DRAW_METADATA) {
                        int x, y;
@@ -748,16 +769,18 @@ void draw_image_main(const bContext *C, ARegion *ar)
        ED_space_image_release_buffer(sima, ibuf, lock);
 
        /* paint helpers */
-       if (show_paint)
+       if (show_paint) {
                draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
+       }
 
        if (show_viewer) {
                BLI_thread_unlock(LOCK_DRAW_IMAGE);
        }
 
        /* render info */
-       if (ima && show_render)
+       if (ima && show_render) {
                draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy);
+       }
 }
 
 bool ED_space_image_show_cache(SpaceImage *sima)
index c8edccb..c838c6a 100644 (file)
@@ -74,13 +74,15 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Object *obedit, Image *im
                }
        }
 
-       if (sima->image)
+       if (sima->image) {
                BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+       }
 
        id_us_ensure_real((ID *)sima->image);
 
-       if (obedit)
+       if (obedit) {
                WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
+       }
 
        WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
 }
@@ -147,22 +149,25 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **r_lock)
                ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, r_lock);
 
                if (ibuf) {
-                       if (ibuf->rect || ibuf->rect_float)
+                       if (ibuf->rect || ibuf->rect_float) {
                                return ibuf;
+                       }
                        BKE_image_release_ibuf(sima->image, ibuf, *r_lock);
                        *r_lock = NULL;
                }
        }
-       else
+       else {
                *r_lock = NULL;
+       }
 
        return NULL;
 }
 
 void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock)
 {
-       if (sima && sima->image)
+       if (sima && sima->image) {
                BKE_image_release_ibuf(sima->image, ibuf, lock);
+       }
 }
 
 bool ED_space_image_has_buffer(SpaceImage *sima)
@@ -335,7 +340,9 @@ bool ED_image_slot_cycle(struct Image *image, int direction)
        int num_slots = BLI_listbase_count(&image->renderslots);
        for (i = 1; i < num_slots; i++) {
                slot = (cur + ((direction == -1) ? -i : i)) % num_slots;
-               if (slot < 0) slot += num_slots;
+               if (slot < 0) {
+                       slot += num_slots;
+               }
 
                RenderSlot *render_slot = BKE_image_get_renderslot(image, slot);
                if ((render_slot && render_slot->render) || slot == image->last_render_slot) {
@@ -357,10 +364,12 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s
        Object *ob = CTX_data_active_object(C);
 
        /* scope update can be expensive, don't update during paint modes */
-       if (sima->mode == SI_MODE_PAINT)
+       if (sima->mode == SI_MODE_PAINT) {
                return;
-       if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0))
+       }
+       if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) {
                return;
+       }
 
        /* We also don't update scopes of render result during render. */
        if (G.is_rendering) {
@@ -382,8 +391,9 @@ bool ED_space_image_show_render(SpaceImage *sima)
 
 bool ED_space_image_show_paint(SpaceImage *sima)
 {
-       if (ED_space_image_show_render(sima))
+       if (ED_space_image_show_render(sima)) {
                return false;
+       }
 
        return (sima->mode == SI_MODE_PAINT);
 }
@@ -442,8 +452,9 @@ bool ED_space_image_paint_curve(const bContext *C)
        if (sima && sima->mode == SI_MODE_PAINT) {
                Brush *br = CTX_data_tool_settings(C)->imapaint.paint.brush;
 
-               if (br && (br->flag & BRUSH_CURVE))
+               if (br && (br->flag & BRUSH_CURVE)) {
                        return true;
+               }
        }
 
        return false;
index 9cbb426..831be93 100644 (file)
@@ -117,12 +117,15 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, const float
                width *= sima->zoom;
                height *= sima->zoom;
 
-               if ((width < 4) && (height < 4) && sima->zoom < oldzoom)
+               if ((width < 4) && (height < 4) && sima->zoom < oldzoom) {
                        sima->zoom = oldzoom;
-               else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom)
+               }
+               else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) {
                        sima->zoom = oldzoom;
-               else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom)
+               }
+               else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) {
                        sima->zoom = oldzoom;
+               }
        }
 
        if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
@@ -489,8 +492,9 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
                ED_region_tag_redraw(CTX_wm_region(C));
        }
 
-       if (vpd->timer)
+       if (vpd->timer) {
                WM_event_remove_timer(CTX_wm_manager(C), vpd->timer->win, vpd->timer);
+       }
 
        WM_cursor_modal_restore(CTX_wm_window(C));
        MEM_freeN(op->customdata);
@@ -534,8 +538,9 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
 
                delta = event->prevx - event->x + event->prevy - event->y;
 
-               if (U.uiflag & USER_ZOOM_INVERT)
+               if (U.uiflag & USER_ZOOM_INVERT) {
                        delta *= -1;
+               }
 
                factor = 1.0f + delta / 300.0f;
                RNA_float_set(op->ptr, "factor", factor);
@@ -582,8 +587,9 @@ static void image_zoom_apply(ViewZoomData *vpd, wmOperator *op, const int x, con
                /* for now do the same things for scale and dolly */
                float delta = x - vpd->origx + y - vpd->origy;
 
-               if (zoom_invert)
+               if (zoom_invert) {
                        delta *= -1.0f;
+               }
 
                factor = 1.0f + delta / 300.0f;
        }
@@ -662,8 +668,9 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
 
 static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
-       if (event->type != NDOF_MOTION)
+       if (event->type != NDOF_MOTION) {
                return OPERATOR_CANCELLED;
+       }
        else {
                SpaceImage *sima = CTX_wm_space_image(C);
                ARegion *ar = CTX_wm_region(C);
@@ -747,8 +754,9 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
                        /* find the zoom value that will fit the image in the image space */
                        sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
                }
-               else
+               else {
                        sima_zoom_set(sima, ar, 1.0f, NULL);
+               }
        }
 
        sima->xof = sima->yof = 0.0f;
@@ -1138,8 +1146,12 @@ static int image_cmp_frame(const void *a, const void *b)
        const ImageFrame *frame_a = a;
        const ImageFrame *frame_b = b;
 
-       if (frame_a->framenr < frame_b->framenr) return -1;
-       if (frame_a->framenr > frame_b->framenr) return 1;
+       if (frame_a->framenr < frame_b->framenr) {
+               return -1;
+       }
+       if (frame_a->framenr > frame_b->framenr) {
+               return 1;
+       }
        return 0;
 }
 
@@ -1181,7 +1193,9 @@ static Image *image_open_single(
        ima = BKE_image_load_exists_ex(bmain, filepath, &exists);
 
        if (!ima) {
-               if (op->customdata) MEM_freeN(op->customdata);
+               if (op->customdata) {
+                       MEM_freeN(op->customdata);
+               }
                BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s",
                            filepath, errno ? strerror(errno) : TIP_("unsupported image format"));
                return NULL;
@@ -1232,8 +1246,9 @@ static int image_open_exec(bContext *C, wmOperator *op)
        const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
        const bool use_multiview    = RNA_boolean_get(op->ptr, "use_multiview");
 
-       if (!op->customdata)
+       if (!op->customdata) {
                image_open_init(C, op);
+       }
 
        RNA_string_get(op->ptr, "filepath", filepath);
 
@@ -1361,8 +1376,9 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
 
        if (ima == NULL) {
                Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
-               if (tex && tex->type == TEX_IMAGE)
+               if (tex && tex->type == TEX_IMAGE) {
                        ima = tex->ima;
+               }
        }
 
        if (ima == NULL) {
@@ -1385,11 +1401,13 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
                }
        }
 
-       if (ima)
+       if (ima) {
                path = ima->name;
+       }
 
-       if (RNA_struct_property_is_set(op->ptr, "filepath"))
+       if (RNA_struct_property_is_set(op->ptr, "filepath")) {
                return image_open_exec(C, op);
+       }
 
        image_open_init(C, op);
 
@@ -1428,8 +1446,9 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
        RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
 
        /* multiview template */
-       if (RNA_boolean_get(op->ptr, "show_multiview"))
+       if (RNA_boolean_get(op->ptr, "show_multiview")) {
                uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+       }
 }
 
 /* called by other space types too */
@@ -1481,12 +1500,14 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
 
        }
 
-       if (!ima || !iuser || !BKE_image_has_anim(ima))
+       if (!ima || !iuser || !BKE_image_has_anim(ima)) {
                return OPERATOR_CANCELLED;
+       }
 
        struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
-       if (!anim)
+       if (!anim) {
                return OPERATOR_CANCELLED;
+       }
        iuser->frames = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
        BKE_image_user_frame_calc(iuser, scene->r.cfra);
 
@@ -1517,8 +1538,9 @@ static int image_replace_exec(bContext *C, wmOperator *op)
        SpaceImage *sima = CTX_wm_space_image(C);
        char str[FILE_MAX];
 
-       if (!sima->image)
+       if (!sima->image) {
                return OPERATOR_CANCELLED;
+       }
 
        RNA_string_get(op->ptr, "filepath", str);
 
@@ -1530,10 +1552,12 @@ static int image_replace_exec(bContext *C, wmOperator *op)
                BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
        }
 
-       if (BLI_path_extension_check_array(str, imb_ext_movie))
+       if (BLI_path_extension_check_array(str, imb_ext_movie)) {
                sima->image->source = IMA_SRC_MOVIE;
-       else
+       }
+       else {
                sima->image->source = IMA_SRC_FILE;
+       }
 
        /* XXX unpackImage frees image buffers */
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1549,14 +1573,17 @@ static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
 {
        SpaceImage *sima = CTX_wm_space_image(C);
 
-       if (!sima->image)
+       if (!sima->image) {
                return OPERATOR_CANCELLED;
+       }
 
-       if (RNA_struct_property_is_set(op->ptr, "filepath"))
+       if (RNA_struct_property_is_set(op->ptr, "filepath")) {
                return image_replace_exec(C, op);
+       }
 
-       if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+       if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
                RNA_boolean_set(op->ptr, "relative_path", BLI_path_is_rel(sima->image->name));
+       }
 
        image_filesel(C, op, sima->image->name);
 
@@ -1604,18 +1631,18 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
        const char depth_ok = BKE_imtype_valid_depths(imtype);
 
        if (ibuf->rect_float) {
-               if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32;
-               if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24;
-               if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16;
-               if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12;
+               if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; }
                return R_IMF_CHAN_DEPTH_8;
        }
        else {
-               if (depth_ok & R_IMF_CHAN_DEPTH_8) return R_IMF_CHAN_DEPTH_8;
-               if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12;
-               if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16;
-               if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24;
-               if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32;
+               if (depth_ok & R_IMF_CHAN_DEPTH_8)  { return R_IMF_CHAN_DEPTH_8; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; }
+               if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; }
                return R_IMF_CHAN_DEPTH_8; /* fallback, should not get here */
        }
 }
@@ -1753,14 +1780,18 @@ static void save_image_post(
                                /* workaround to ensure the render result buffer is no longer used
                                 * by this image, otherwise can crash when a new render result is
                                 * created. */
-                               if (ibuf->rect && !(ibuf->mall & IB_rect))
+                               if (ibuf->rect && !(ibuf->mall & IB_rect)) {
                                        imb_freerectImBuf(ibuf);
-                               if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat))
+                               }
+                               if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) {
                                        imb_freerectfloatImBuf(ibuf);
-                               if (ibuf->zbuf && !(ibuf->mall & IB_zbuf))
+                               }
+                               if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) {
                                        IMB_freezbufImBuf(ibuf);
-                               if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat))
+                               }
+                               if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) {
                                        IMB_freezbuffloatImBuf(ibuf);
+                               }
                        }
                        if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
                                ima->source = IMA_SRC_FILE;
@@ -1932,10 +1963,12 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                                        iuser.view = i;
                                        iuser.flag &= ~IMA_SHOW_STEREO;
 
-                                       if (rr)
+                                       if (rr) {
                                                BKE_image_multilayer_index(rr, &iuser);
-                                       else
+                                       }
+                                       else {
                                                BKE_image_multiview_index(ima, &iuser);
+                                       }
 
                                        ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock);
                                        ibuf->planes = planes;
@@ -2087,13 +2120,15 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
        PropertyRNA *prop;
        const bool save_as_render = ((ima->source == IMA_SRC_VIEWER) || (ima->flag & IMA_VIEW_AS_RENDER));
 
-       if (RNA_struct_property_is_set(op->ptr, "filepath"))
+       if (RNA_struct_property_is_set(op->ptr, "filepath")) {
                return image_save_as_exec(C, op);
+       }
 
        save_image_options_defaults(&simopts);
 
-       if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0)
+       if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0) {
                return OPERATOR_CANCELLED;
+       }
        save_image_options_to_op(&simopts, op);
 
        /* enable save_copy by default for render results */
@@ -2150,8 +2185,9 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
        uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
 
        /* multiview template */
-       if (is_multiview)
+       if (is_multiview) {
                uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+       }
 }
 
 static bool image_save_as_poll(bContext *C)
@@ -2209,8 +2245,9 @@ static int image_save_exec(bContext *C, wmOperator *op)
        SaveImageOptions simopts;
 
        save_image_options_defaults(&simopts);
-       if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0)
+       if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0) {
                return OPERATOR_CANCELLED;
+       }
        save_image_options_from_op(bmain, &simopts, op);
 
        if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
@@ -2253,8 +2290,9 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
        char di[FILE_MAX];
        struct MovieCacheIter *iter;
 
-       if (sima->image == NULL)
+       if (sima->image == NULL) {
                return OPERATOR_CANCELLED;
+       }
 
        if (sima->image->source != IMA_SRC_SEQUENCE) {
                BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences");
@@ -2341,8 +2379,9 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
        Image *ima = CTX_data_edit_image(C);
        SpaceImage *sima = CTX_wm_space_image(C);
 
-       if (!ima)
+       if (!ima) {
                return OPERATOR_CANCELLED;
+       }
 
        /* XXX unpackImage frees image buffers */
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -2437,8 +2476,9 @@ static int image_new_exec(bContext *C, wmOperator *op)
        alpha = RNA_boolean_get(op->ptr, "alpha");
        stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d");
 
-       if (!alpha)
+       if (!alpha) {
                color[3] = 1.0f;
+       }
 
        ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d);
 
@@ -2619,10 +2659,10 @@ static int image_invert_exec(bContext *C, wmOperator *op)
 
                float *fp = (float *) ibuf->rect_float;
                for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) {
-                       if (r) fp[0] = 1.0f - fp[0];
-                       if (g) fp[1] = 1.0f - fp[1];
-                       if (b) fp[2] = 1.0f - fp[2];
-                       if (a) fp[3] = 1.0f - fp[3];
+                       if (r) { fp[0] = 1.0f - fp[0]; }
+                       if (g) { fp[1] = 1.0f - fp[1]; }
+                       if (b) { fp[2] = 1.0f - fp[2]; }
+                       if (a) { fp[3] = 1.0f - fp[3]; }
                }
 
                if (ibuf->rect) {
@@ -2633,10 +2673,10 @@ static int image_invert_exec(bContext *C, wmOperator *op)
 
                char *cp = (char *) ibuf->rect;
                for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) {
-                       if (r) cp[0] = 255 - cp[0];
-                       if (g) cp[1] = 255 - cp[1];
-                       if (b) cp[2] = 255 - cp[2];
-                       if (a) cp[3] = 255 - cp[3];
+                       if (r) { cp[0] = 255 - cp[0]; }
+                       if (g) { cp[1] = 255 - cp[1]; }
+                       if (b) { cp[2] = 255 - cp[2]; }
+                       if (a) { cp[3] = 255 - cp[3]; }
                }
        }
        else {
@@ -2646,8 +2686,9 @@ static int image_invert_exec(bContext *C, wmOperator *op)
 
        ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
 
-       if (ibuf->mipmap[0])
+       if (ibuf->mipmap[0]) {
                ibuf->userflags |= IB_MIPMAP_INVALID;
+       }
 
        if (support_undo) {
                ED_image_undo_push_end();
@@ -2697,10 +2738,12 @@ static bool image_pack_test(bContext *C, wmOperator *op)
        Image *ima = CTX_data_edit_image(C);
        const bool as_png = RNA_boolean_get(op->ptr, "as_png");
 
-       if (!ima)
+       if (!ima) {
                return 0;
-       if (!as_png && BKE_image_has_packedfile(ima))
+       }
+       if (!as_png && BKE_image_has_packedfile(ima)) {
                return 0;
+       }
 
        if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
                BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported");
@@ -2717,18 +2760,21 @@ static int image_pack_exec(bContext *C, wmOperator *op)
        ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
        const bool as_png = RNA_boolean_get(op->ptr, "as_png");
 
-       if (!image_pack_test(C, op))
+       if (!image_pack_test(C, op)) {
                return OPERATOR_CANCELLED;
+       }
 
        if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
                BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
                return OPERATOR_CANCELLED;
        }
 
-       if (as_png)
+       if (as_png) {
                BKE_image_memorypack(ima);
-       else
+       }
+       else {
                BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id));
+       }
 
        WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
 
@@ -2745,8 +2791,9 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
        uiLayout *layout;
        const bool as_png = RNA_boolean_get(op->ptr, "as_png");
 
-       if (!image_pack_test(C, op))
+       if (!image_pack_test(C, op)) {
                return OPERATOR_CANCELLED;
+       }
 
        ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
 
@@ -2797,19 +2844,23 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
                char imaname[MAX_ID_NAME - 2];
                RNA_string_get(op->ptr, "id", imaname);
                ima = BLI_findstring(&CTX_data_main(C)->images, imaname, offsetof(ID, name) + 2);
-               if (!ima) ima = CTX_data_edit_image(C);
+               if (!ima) {
+                       ima = CTX_data_edit_image(C);
+               }
        }
 
-       if (!ima || !BKE_image_has_packedfile(ima))
+       if (!ima || !BKE_image_has_packedfile(ima)) {
                return OPERATOR_CANCELLED;
+       }
 
        if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
                BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
                return OPERATOR_CANCELLED;
        }
 
-       if (G.fileflags & G_FILE_AUTOPACK)
+       if (G.fileflags & G_FILE_AUTOPACK) {
                BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save");
+       }
 
        /* XXX unpackImage frees image buffers */
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -2825,19 +2876,22 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
 {
        Image *ima = CTX_data_edit_image(C);
 
-       if (RNA_struct_property_is_set(op->ptr, "id"))
+       if (RNA_struct_property_is_set(op->ptr, "id")) {
                return image_unpack_exec(C, op);
+       }
 
-       if (!ima || !BKE_image_has_packedfile(ima))
+       if (!ima || !BKE_image_has_packedfile(ima)) {
                return OPERATOR_CANCELLED;
+       }
 
        if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
                BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
                return OPERATOR_CANCELLED;
        }
 
-       if (G.fileflags & G_FILE_AUTOPACK)
+       if (G.fileflags & G_FILE_AUTOPACK) {
                BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save");
+       }
 
        unpack_menu(C, "IMAGE_OT_unpack", ima->id.name + 2, ima->name, "textures", BKE_image_has_packedfile(ima) ? ((ImagePackedFile *)ima->packedfiles.first)->packedfile : NULL);
 
@@ -3209,8 +3263,9 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event
                }
        }
 
-       if (!ED_space_image_has_buffer(sima))
+       if (!ED_space_image_has_buffer(sima)) {
                return OPERATOR_CANCELLED;
+       }
 
        info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
 
@@ -3329,8 +3384,9 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *
        Histogram *hist = &sima->sample_line_hist;
        hist->flag &= ~HISTO_FLAG_SAMPLELINE;
 
-       if (!ED_space_image_has_buffer(sima))
+       if (!ED_space_image_has_buffer(sima)) {
                return OPERATOR_CANCELLED;
+       }
 
        return WM_gesture_straightline_invoke(C, op, event);
 }
@@ -3559,8 +3615,9 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
 
        /* no undo push for browsing existing */
        RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot);
-       if ((slot && slot->render) || ima->render_slot == ima->last_render_slot)
+       if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) {
                return OPERATOR_CANCELLED;
+       }
 
        return OPERATOR_FINISHED;
 }
@@ -3678,8 +3735,9 @@ void IMAGE_OT_remove_render_slot(wmOperatorType *ot)
 static bool change_frame_poll(bContext *C)
 {
        /* prevent changes during render */
-       if (G.is_rendering)
+       if (G.is_rendering) {
                return 0;
+       }
 
        return space_image_main_region_poll(C);
 }
@@ -3761,8 +3819,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
                case LEFTMOUSE:
                case RIGHTMOUSE:
-                       if (event->val == KM_RELEASE)
+                       if (event->val == KM_RELEASE) {
                                return OPERATOR_FINISHED;
+                       }
                        break;
        }
 
index 7aa3ea5..d5eb0b4 100644 (file)
@@ -91,8 +91,9 @@ static void image_scopes_tag_refresh(ScrArea *sa)
 
        /* only while histogram is visible */
        for (ar = sa->regionbase.first; ar; ar = ar->next) {
-               if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN)
+               if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN) {
                        return;
+               }
        }
 
        sima->scopes.ok = 0;
@@ -122,13 +123,17 @@ ARegion *image_has_buttons_region(ScrArea *sa)
        ARegion *ar, *arnew;
 
        ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
-       if (ar) return ar;
+       if (ar) {
+               return ar;
+       }
 
        /* add subdiv level; after header */
        ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
 
        /* is error! */
-       if (ar == NULL) return NULL;
+       if (ar == NULL) {
+               return NULL;
+       }
 
        arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
 
@@ -146,13 +151,17 @@ ARegion *image_has_tools_region(ScrArea *sa)
        ARegion *ar, *arnew;
 
        ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
-       if (ar) return ar;
+       if (ar) {
+               return ar;
+       }
 
        /* add subdiv level; after buttons */
        ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
 
        /* is error! */
-       if (ar == NULL) return NULL;
+       if (ar == NULL) {
+               return NULL;
+       }
 
        arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
 
@@ -371,15 +380,17 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
                                        ED_area_tag_redraw(sa);
                                        break;
                                case ND_MODE:
-                                       if (wmn->subtype == NS_EDITMODE_MESH)
+                                       if (wmn->subtype == NS_EDITMODE_MESH) {
                                                ED_area_tag_refresh(sa);
+                                       }
                                        ED_area_tag_redraw(sa);
                                        break;
                                case ND_RENDER_RESULT:
                                case ND_RENDER_OPTIONS:
                                case ND_COMPO_RESULT:
-                                       if (ED_space_image_show_render(sima))
+                                       if (ED_space_image_show_render(sima)) {
                                                image_scopes_tag_refresh(sa);
+                                       }
                                        ED_area_tag_redraw(sa);
                                        break;
                        }
@@ -532,8 +543,9 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
        float w = width;
        float h = height;
 
-       if (ima)
+       if (ima) {
                h *= ima->aspy / ima->aspx;
+       }
 
        int winx = BLI_rcti_size_x(&ar->winrct) + 1;
        int winy = BLI_rcti_size_y(&ar->winrct) + 1;
@@ -703,8 +715,9 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
                ED_space_image_get_size(sima, &width, &height);
                ED_space_image_get_aspect(sima, &aspx, &aspy);
 
-               if (show_viewer)
+               if (show_viewer) {
                        BLI_thread_unlock(LOCK_DRAW_IMAGE);
+               }
 
                ED_mask_draw_region(mask, ar,
                                    sima->mask_info.draw_flag,
@@ -744,26 +757,31 @@ static void image_main_region_listener(
        /* context changes */
        switch (wmn->category) {
                case NC_GEOM:
-                       if (ELEM(wmn->data, ND_DATA, ND_SELECT))
+                       if (ELEM(wmn->data, ND_DATA, ND_SELECT)) {
                                WM_gizmomap_tag_refresh(ar->gizmo_map);
+                       }
                        break;
                case NC_GPENCIL:
-                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
                                ED_region_tag_redraw(ar);
-                       else if (wmn->data & ND_GPENCIL_EDITMODE)
+                       }
+                       else if (wmn->data & ND_GPENCIL_EDITMODE) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_IMAGE:
-                       if (wmn->action == NA_PAINTING)
+                       if (wmn->action == NA_PAINTING) {
                                ED_region_tag_redraw(ar);
+                       }
                        WM_gizmomap_tag_refresh(ar->gizmo_map);
                        break;
                case NC_MATERIAL:
                        if (wmn->data == ND_SHADING_LINKS) {
                                SpaceImage *sima = sa->spacedata.first;
 
-                               if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE))
+                               if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) {
                                        ED_region_tag_redraw(ar);
+                               }
                        }
                        break;
                case NC_SCREEN:
@@ -803,10 +821,12 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
                        if (!sima->scopes.ok) {
                                BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
                        }
-                       if (sima->image->flag & IMA_VIEW_AS_RENDER)
+                       if (sima->image->flag & IMA_VIEW_AS_RENDER) {
                                ED_space_image_scopes_update(C, sima, ibuf, true);
-                       else
+                       }
+                       else {
                                ED_space_image_scopes_update(C, sima, ibuf, false);
+                       }
                }
        }
        ED_space_image_release_buffer(sima, ibuf, lock);
@@ -836,15 +856,17 @@ static void image_buttons_region_listener(
                        }
                        break;
                case NC_IMAGE:
-                       if (wmn->action != NA_PAINTING)
+                       if (wmn->action != NA_PAINTING) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_NODE:
                        ED_region_tag_redraw(ar);
                        break;
                case NC_GPENCIL:
-                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
        }
 }
@@ -875,13 +897,15 @@ static void image_tools_region_listener(
        /* context changes */
        switch (wmn->category) {
                case NC_GPENCIL:
-                       if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+                       if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_BRUSH:
                        /* NA_SELECTED is used on brush changes */
-                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+                       if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_SCENE:
                        switch (wmn->data) {
@@ -893,8 +917,9 @@ static void image_tools_region_listener(
                        }
                        break;
                case NC_IMAGE:
-                       if (wmn->action != NA_PAINTING)
+                       if (wmn->action != NA_PAINTING) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_NODE:
                        ED_region_tag_redraw(ar);
index 538c41f..4f7e0f7 100644 (file)
@@ -219,7 +219,9 @@ static int unpack_all_exec(bContext *C, wmOperator *op)
        Main *bmain = CTX_data_main(C);
        int method = RNA_enum_get(op->ptr, "method");
 
-       if (method != PF_KEEP) unpackAll(bmain, op->reports, method);  /* XXX PF_ASK can't work here */
+       if (method != PF_KEEP) {
+               unpackAll(bmain, op->reports, method);  /* XXX PF_ASK can't work here */
+       }
        G.fileflags &= ~G_FILE_AUTOPACK;
 
        return OPERATOR_FINISHED;
@@ -241,10 +243,12 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
                return OPERATOR_CANCELLED;
        }
 
-       if (count == 1)
+       if (count == 1) {
                BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title));
-       else
+       }
+       else {
                BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count);
+       }
 
        pup = UI_popup_menu_begin(C, title, ICON_NONE);
        layout = UI_popup_menu_layout(pup);
@@ -303,8 +307,9 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       if (method != PF_KEEP)
+       if (method != PF_KEEP) {
                BKE_unpack_id(bmain, id, op->reports, method);  /* XXX PF_ASK can't work here */
+       }
 
        G.fileflags &= ~G_FILE_AUTOPACK;
 
index 73c36f6..a8f5d9b 100644 (file)
@@ -111,8 +111,9 @@ static int select_report_pick_exec(bContext *C, wmOperator *op)
        int report_index = RNA_int_get(op->ptr, "report_index");
        Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
 
-       if (!report)
+       if (!report) {
                return OPERATOR_CANCELLED;
+       }
 
        report->flag ^= SELECT; /* toggle */
 
index fdcc915..054e9cd 100644 (file)
@@ -128,7 +128,9 @@ static void stats_object(Object *ob, SceneStats *stats)
        const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0;
 
        stats->totobj++;
-       if (is_selected) stats->totobjsel++;
+       if (is_selected) {
+               stats->totobjsel++;
+       }
 
        switch (ob->type) {
                case OB_MESH:
@@ -158,8 +160,9 @@ static void stats_object(Object *ob, SceneStats *stats)
                {
                        int totv = 0, totf = 0, tottri = 0;
 
-                       if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first)
+                       if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) {
                                BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri);
+                       }
 
                        stats->totvert += totv;
                        stats->totface += totf;
@@ -214,15 +217,20 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
                for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
                        stats->totbone++;
 
-                       if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
+                       if ((ebo->flag & BONE_CONNECTED) && ebo->parent) {
                                stats->totvert--;
+                       }
 
-                       if (ebo->flag & BONE_TIPSEL)
+                       if (ebo->flag & BONE_TIPSEL) {
                                stats->totvertsel++;
-                       if (ebo->flag & BONE_ROOTSEL)
+                       }
+                       if (ebo->flag & BONE_ROOTSEL) {
                                stats->totvertsel++;
+                       }
 
-                       if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
+                       if (ebo->flag & BONE_SELECTED) {
+                               stats->totbonesel++;
+                       }
 
                        /* if this is a connected child and it's parent is being moved, remove our root */
                        if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) &&
@@ -249,9 +257,15 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
                                a = nu->pntsu;
                                while (a--) {
                                        stats->totvert += 3;
-                                       if (bezt->f1 & SELECT) stats->totvertsel++;
-                                       if (bezt->f2 & SELECT) stats->totvertsel++;
-                                       if (bezt->f3 & SELECT) stats->totvertsel++;
+                                       if (bezt->f1 & SELECT) {
+                                               stats->totvertsel++;
+                                       }
+                                       if (bezt->f2 & SELECT) {
+                                               stats->totvertsel++;
+                                       }
+                                       if (bezt->f3 & SELECT) {
+                                               stats->totvertsel++;
+                                       }
                                        bezt++;
                                }
                        }
@@ -260,7 +274,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
                                a = nu->pntsu * nu->pntsv;
                                while (a--) {
                                        stats->totvert++;
-                                       if (bp->f1 & SELECT) stats->totvertsel++;
+                                       if (bp->f1 & SELECT) {
+                                               stats->totvertsel++;
+                                       }
                                        bp++;
                                }
                        }
@@ -273,7 +289,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
 
                for (ml = mball->editelems->first; ml; ml = ml->next) {
                        stats->totvert++;
-                       if (ml->flag & SELECT) stats->totvertsel++;
+                       if (ml->flag & SELECT) {
+                               stats->totvertsel++;
+                       }
                }
        }
        else if (obedit->type == OB_LATTICE) {
@@ -288,7 +306,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
                a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
                while (a--) {
                        stats->totvert++;
-                       if (bp->f1 & SELECT) stats->totvertsel++;
+                       if (bp->f1 & SELECT) {
+                               stats->totvertsel++;
+                       }
                        bp++;
                }
        }
@@ -302,9 +322,11 @@ static void stats_object_pose(Object *ob, SceneStats *stats)
 
                for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                        stats->totbone++;
-                       if (pchan->bone && (pchan->bone->flag & BONE_SELECTED))
-                               if (pchan->bone->layer & arm->layer)
+                       if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
+                               if (pchan->bone->layer & arm->layer) {
                                        stats->totbonesel++;
+                               }
+                       }
                }
        }
 }
@@ -448,8 +470,9 @@ static void stats_string(ViewLayer *view_layer)
        }
 
        if (obedit) {
-               if (BKE_keyblock_from_object(obedit))
+               if (BKE_keyblock_from_object(obedit)) {
                        ofs += BLI_strncpy_rlen(s + ofs, IFACE_("(Key) "), MAX_INFO_LEN - ofs);
+               }
 
                if (obedit->type == OB_MESH) {
                        ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs,
index 754941a..997a408 100644 (file)
@@ -151,8 +151,9 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
        GPU_clear(GPU_COLOR_BIT);
 
        /* quick way to avoid drawing if not bug enough */
-       if (ar->winy < 16)
+       if (ar->winy < 16) {
                return;
+       }
 
        info_textview_update_rect(C, ar);
 
@@ -241,20 +242,24 @@ static void info_header_listener(
                        }
                        break;
                case NC_WM:
-                       if (wmn->data == ND_JOB)
+                       if (wmn->data == ND_JOB) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_SCENE:
-                       if (wmn->data == ND_RENDER_RESULT)
+                       if (wmn->data == ND_RENDER_RESULT) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_SPACE:
-                       if (wmn->data == ND_SPACE_INFO)
+                       if (wmn->data == ND_SPACE_INFO) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_ID:
-                       if (wmn->action == NA_RENAME)
+                       if (wmn->action == NA_RENAME) {
                                ED_region_tag_redraw(ar);
+                       }
                        break;
        }
 
index a335d6d..7585cda 100644 (file)
@@ -291,11 +291,13 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
 
        xy[0] = x_orig; xy[1] = y_orig;
 
-       if (mval[1] != INT_MAX)
+       if (mval[1] != INT_MAX) {
                mval[1] += (tvc->ymin + CONSOLE_DRAW_MARGIN);
+       }
 
-       if (pos_pick)
+       if (pos_pick) {
                *pos_pick = 0;
+       }
 
        /* constants for the sequencer context */
        cdc.font_id = font_id;
@@ -306,8 +308,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
        /* note, scroll bar must be already subtracted () */
        cdc.console_width = (tvc->winx - (CONSOLE_DRAW_MARGIN * 2)) / cdc.cwidth;
        /* avoid divide by zero on small windows */
-       if (cdc.console_width < 1)
+       if (cdc.console_width < 1) {
                cdc.console_width = 1;
+       }
        cdc.winx = tvc->winx - CONSOLE_DRAW_MARGIN;
        cdc.ymin = tvc->ymin;
        cdc.ymax = tvc->ymax;
@@ -341,8 +344,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
 
                        y_prev = xy[1];
 
-                       if (draw)
+                       if (draw) {
                                color_flag = tvc->line_color(tvc, fg, bg);
+                       }
 
                        tvc->line_get(tvc, &ext_line, &ext_len);
 
index 60dcdae..be26f67 100644 (file)
@@ -115,8 +115,9 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
        col = uiLayoutColumn(layout, false);
        row = uiLayoutRow(col, true);
        uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
-       if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE))
+       if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) {
                uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
+       }
 
        uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
 }
@@ -257,20 +258,24 @@ static int node_resize_area_default(bNode *node, int x, int y)
                rctf totr = node->totr;
                /* right part of node */
                totr.xmin = node->totr.xmax - 20.0f;
-               if (BLI_rctf_isect_pt(&totr, x, y))
+               if (BLI_rctf_isect_pt(&totr, x, y)) {
                        return NODE_RESIZE_RIGHT;
-               else
+               }
+               else {
                        return 0;
+               }
        }
        else {
                const float size = NODE_RESIZE_MARGIN;
                rctf totr = node->totr;
                int dir = 0;
 
-               if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
+               if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
                        dir |= NODE_RESIZE_RIGHT;
-               if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
+               }
+               if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
                        dir |= NODE_RESIZE_LEFT;
+               }
                return dir;
        }
 }
@@ -306,8 +311,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
        bbinit = (data->flag & NODE_FRAME_SHRINK);
        /* fit bounding box to all children */
        for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
-               if (tnode->parent != node)
+               if (tnode->parent != node) {
                        continue;
+               }
 
                /* add margin to node rect */
                noderect = tnode->totr;
@@ -322,8 +328,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
                        rect = noderect;
                        data->flag &= ~NODE_FRAME_RESIZEABLE;
                }
-               else
+               else {
                        BLI_rctf_union(&rect, &noderect);
+               }
        }
 
        /* now adjust the frame size from view-space bounding box */
@@ -445,18 +452,21 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
        if (node->flag & NODE_CUSTOM_COLOR) {
                rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
        }
-       else
+       else {
                UI_GetThemeColor4fv(TH_NODE_FRAME, color);
+       }
 
        UI_draw_roundbox_corner_set(UI_CNR_ALL);
        UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
 
        /* outline active and selected emphasis */
        if (node->flag & SELECT) {
-               if (node->flag & NODE_ACTIVE)
+               if (node->flag & NODE_ACTIVE) {
                        UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color);
-               else
+               }
+               else {
                        UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color);
+               }
 
                UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
        }
@@ -479,17 +489,22 @@ static int node_resize_area_frame(bNode *node, int x, int y)
        int dir = 0;
 
        /* shrinking frame size is determined by child nodes */
-       if (!(data->flag & NODE_FRAME_RESIZEABLE))
+       if (!(data->flag & NODE_FRAME_RESIZEABLE)) {
                return 0;
+       }
 
-       if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
+       if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
                dir |= NODE_RESIZE_RIGHT;
-       if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
+       }
+       if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
                dir |= NODE_RESIZE_LEFT;
-       if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
+       }
+       if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax) {
                dir |= NODE_RESIZE_TOP;
-       if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
+       }
+       if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) {
                dir |= NODE_RESIZE_BOTTOM;
+       }
 
        return dir;
 }
@@ -636,8 +651,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
        uiLayout *col;
        int source;
 
-       if (!imaptr->data)
+       if (!imaptr->data) {
                return;
+       }
 
        col = uiLayoutColumn(layout, false);
 
@@ -790,8 +806,9 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
                layout, C, ptr, "image",
                "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
 
-       if (!ima)
+       if (!ima) {
                return;
+       }
 
        uiItemR(layout, &imaptr, "source", 0, IFACE_("Source"), ICON_NONE);
 
@@ -799,10 +816,12 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
                uiLayout *row = uiLayoutRow(layout, true);
                const bool is_packed = BKE_image_has_packedfile(ima);
 
-               if (is_packed)
+               if (is_packed) {
                        uiItemO(row, "", ICON_PACKAGE, "image.unpack");
-               else
+               }
+               else {
                        uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
+               }
 
                row = uiLayoutRow(row, true);
                uiLayoutSetEnabled(row, !is_packed);
@@ -829,8 +848,9 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin
        uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
        uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
 
-       if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW)
+       if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW) {
                uiItemR(layout, ptr, "ground_albedo", 0, NULL, ICON_NONE);
+       }
 }
 
 static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -903,12 +923,14 @@ static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED
        else {
                uiItemR(layout, ptr, "vertex_color_source", 0, NULL, ICON_NONE);
                if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTWEIGHT) {
-                       if (ob_ptr.data)
+                       if (ob_ptr.data) {
                                uiItemPointerR(layout, ptr, "vertex_attribute_name", &ob_ptr, "vertex_groups", "", ICON_NONE);
+                       }
                }
                if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTCOL) {
-                       if (obdata_ptr.data)
+                       if (obdata_ptr.data) {
                                uiItemPointerR(layout, ptr, "vertex_attribute_name", &obdata_ptr, "vertex_colors", "", ICON_NONE);
+                       }
                }
        }
 }
@@ -954,8 +976,9 @@ static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRN
                        PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
                        uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
                }
-               else
+               else {
                        uiItemR(layout, ptr, "uv_map", 0, "", 0);
+               }
        }
 }
 
@@ -981,11 +1004,13 @@ static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *
                        PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
                        uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
                }
-               else
+               else {
                        uiItemR(row, ptr, "uv_map", 0, "", 0);
+               }
        }
-       else
+       else {
                uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
+       }
 }
 
 static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1034,10 +1059,12 @@ static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerR
 
        row = uiLayoutRow(layout, true);
 
-       if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL)
+       if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) {
                uiItemR(row, ptr, "ies", 0, "", ICON_NONE);
-       else
+       }
+       else {
                uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
+       }
 }
 
 static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1049,10 +1076,12 @@ static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), Point
 
        row = uiLayoutRow(layout, true);
 
-       if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
+       if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) {
                uiItemR(row, ptr, "script", 0, "", ICON_NONE);
-       else
+       }
+       else {
                uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
+       }
 
        uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
 }
@@ -1247,16 +1276,19 @@ static void node_buts_image_views(uiLayout *layout, bContext *UNUSED(C), Pointer
 {
        uiLayout *col;
 
-       if (!imaptr->data)
+       if (!imaptr->data) {
                return;
+       }
 
        col = uiLayoutColumn(layout, false);
 
        if (RNA_boolean_get(ptr, "has_views")) {
-               if (RNA_enum_get(ptr, "view") == 0)
+               if (RNA_enum_get(ptr, "view") == 0) {
                        uiItemR(col, ptr, "view", 0, NULL, ICON_CAMERA_STEREO);
-               else
+               }
+               else {
                        uiItemR(col, ptr, "view", 0, NULL, ICON_SCENE);
+               }
        }
 }
 
@@ -1270,7 +1302,9 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
        uiTemplateID(
                layout, C, ptr, "image",
                "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
-       if (!node->id) return;
+       if (!node->id) {
+               return;
+       }
 
        imaptr = RNA_pointer_get(ptr, "image");
 
@@ -1301,15 +1335,18 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer
 
        uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
 
-       if (!node->id) return;
+       if (!node->id) {
+               return;
+       }
 
        col = uiLayoutColumn(layout, false);
        row = uiLayoutRow(col, true);
        uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
 
        prop = RNA_struct_find_property(ptr, "layer");
-       if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
+       if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) {
                return;
+       }
 
        scn_ptr = RNA_pointer_get(ptr, "scene");
        RNA_string_get(&scn_ptr, "name", scene_name);
@@ -1431,8 +1468,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
        if (RNA_enum_get(ptr, "glare_type") != 1) {
                uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
 
-               if (RNA_enum_get(ptr, "glare_type") != 0)
+               if (RNA_enum_get(ptr, "glare_type") != 0) {
                        uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+               }
        }
 
        uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
@@ -1445,8 +1483,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
        if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
                uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
 
-               if (RNA_enum_get(ptr, "glare_type") == 0)
+               if (RNA_enum_get(ptr, "glare_type") == 0) {
                        uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
+               }
        }
        if (RNA_enum_get(ptr, "glare_type") == 1) {
                uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
@@ -1754,10 +1793,12 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C)
        PointerRNA imfptr = RNA_pointer_get(ptr, "format");
        const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
 
-       if (multilayer)
+       if (multilayer) {
                uiItemL(layout, IFACE_("Path:"), ICON_NONE);
-       else
+       }
+       else {
                uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
+       }
        uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
 }
 static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
@@ -1776,8 +1817,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
 
        /* disable stereo output for multilayer, too much work for something that no one will use */
        /* if someone asks for that we can implement it */
-       if (is_multiview)
+       if (is_multiview) {
                uiTemplateImageFormatViews(layout, &imfptr, NULL);
+       }
 
        uiItemS(layout);
 
@@ -1841,8 +1883,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
                        uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false);
                        uiTemplateImageSettings(col, &imfptr, false);
 
-                       if (is_multiview)
+                       if (is_multiview) {
                                uiTemplateImageFormatViews(layout, &imfptr, NULL);
+                       }
                }
        }
 }
@@ -1991,8 +2034,9 @@ static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, Point
 
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
 
-       if (!node->id)
+       if (!node->id) {
                return;
+       }
 
        clipptr = RNA_pointer_get(ptr, "clip");
 
@@ -2005,8 +2049,9 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe
 
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
 
-       if (!node->id)
+       if (!node->id) {
                return;
+       }
 
        uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
        uiItemR(layout, ptr, "invert", 0, NULL, ICON_NONE);
@@ -2029,8 +2074,9 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po
 
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
 
-       if (!node->id)
+       if (!node->id) {
                return;
+       }
 
        uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
 }
@@ -2913,8 +2959,9 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket
        StructRNA *srna = ntype->ext.srna;
        PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
 
-       if (prop)
+       if (prop) {
                RNA_def_property_update_runtime(prop, node_property_update_default);
+       }
 }
 
 static void node_template_properties_update(bNodeType *ntype)
@@ -2922,12 +2969,14 @@ static void node_template_properties_update(bNodeType *ntype)
        bNodeSocketTemplate *stemp;
 
        if (ntype->inputs) {
-               for (stemp = ntype->inputs; stemp->type >= 0; ++stemp)
+               for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) {
                        node_socket_template_properties_update(ntype, stemp);
+               }
        }
        if (ntype->outputs) {
-               for (stemp = ntype->outputs; stemp->type >= 0; ++stemp)
+               for (stemp = ntype->outputs; stemp->type >= 0; ++stemp) {
                        node_socket_template_properties_update(ntype, stemp);
+               }
        }
 }
 
@@ -3077,8 +3126,9 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR
 
                uiItemL(row, input->path, ICON_NONE);
 
-               if (!RNA_boolean_get(&inputptr, "use_node_format"))
+               if (!RNA_boolean_get(&inputptr, "use_node_format")) {
                        imfptr = RNA_pointer_get(&inputptr, "format");
+               }
 
                imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
                RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
@@ -3206,11 +3256,13 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
        void *lock;
        ImBuf *ibuf;
 
-       if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode))
+       if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) {
                return;
+       }
 
-       if (parent_key.value != active_viewer_key.value)
+       if (parent_key.value != active_viewer_key.value) {
                return;
+       }
 
        ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
@@ -3234,14 +3286,18 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
 
                                display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
 
-                               if (snode->flag & SNODE_SHOW_R)
+                               if (snode->flag & SNODE_SHOW_R) {
                                        shuffle[0] = 1.0f;
-                               else if (snode->flag & SNODE_SHOW_G)
+                               }
+                               else if (snode->flag & SNODE_SHOW_G) {
                                        shuffle[1] = 1.0f;
-                               else if (snode->flag & SNODE_SHOW_B)
+                               }
+                               else if (snode->flag & SNODE_SHOW_B) {
                                        shuffle[2] = 1.0f;
-                               else
+                               }
+                               else {
                                        shuffle[3] = 1.0f;
+                               }
 
                                IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
                                GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle);
@@ -3263,8 +3319,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
                                glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
                        }
 
-                       if (cache_handle)
+                       if (cache_handle) {
                                IMB_display_buffer_release(cache_handle);
+                       }
                }
 
                /** \note draw selected info on backdrop */
@@ -3330,7 +3387,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
                fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE);
        }
        else {
-               if (snode == NULL) return 0;
+               if (snode == NULL) {
+                       return 0;
+               }
                copy_v2_v2(vec[0], cursor);
                fromreroute = 0;
        }
@@ -3340,7 +3399,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
                toreroute = (link->tonode && link->tonode->type == NODE_REROUTE);
        }
        else {
-               if (snode == NULL) return 0;
+               if (snode == NULL) {
+                       return 0;
+               }
                copy_v2_v2(vec[3], cursor);
                toreroute = 0;
        }
@@ -3477,8 +3538,9 @@ static void nodelink_batch_init(void)
                float exp[2] = {0.0f, 1.0f};
 
                /* restart */
-               if (k == 1)
+               if (k == 1) {
                        set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
+               }
 
                /* curve strip */
                for (int i = 0; i < LINK_RESOL; ++i) {
@@ -3508,8 +3570,9 @@ static void nodelink_batch_init(void)
                }
 
                /* restart */
-               if (k == 0)
+               if (k == 0) {
                        set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
+               }
        }
 
        g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
@@ -3548,8 +3611,9 @@ static char nodelink_get_color_id(int th_col)
 
 static void nodelink_batch_draw(SpaceNode *snode)
 {
-       if (g_batch_link.count == 0)
+       if (g_batch_link.count == 0) {
                return;
+       }
 
        GPU_blend(true);
 
@@ -3655,8 +3719,9 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
 {
        int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
 
-       if (link->fromsock == NULL && link->tosock == NULL)
+       if (link->fromsock == NULL && link->tosock == NULL) {
                return;
+       }
 
        /* new connection */
        if (!link->fromsock || !link->tosock) {
@@ -3664,10 +3729,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
        }
        else {
                /* going to give issues once... */
-               if (link->tosock->flag & SOCK_UNAVAIL)
+               if (link->tosock->flag & SOCK_UNAVAIL) {
                        return;
-               if (link->fromsock->flag & SOCK_UNAVAIL)
+               }
+               if (link->fromsock->flag & SOCK_UNAVAIL) {
                        return;
+               }
 
                if (link->flag & NODE_LINK_VALID) {
                        /* special indicated link, on drop-node */
@@ -3676,10 +3743,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
                        }
                        else {
                                /* regular link */
-                               if (link->fromnode && link->fromnode->flag & SELECT)
+                               if (link->fromnode && link->fromnode->flag & SELECT) {
                                        th_col1 = TH_EDGE_SELECT;
-                               if (link->tonode && link->tonode->flag & SELECT)
+                               }
+                               if (link->tonode && link->tonode->flag & SELECT) {
                                        th_col2 = TH_EDGE_SELECT;
+                               }
                        }
                }
                else {
index 6cb45f8..814496c 100644 (file)
@@ -65,10 +65,12 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
 
        node_deselect_all(snode);
 
-       if (idname)
+       if (idname) {
                node = nodeAddNode(C, snode->edittree, idname);
-       else
+       }
+       else {
                node = nodeAddStaticNode(C, snode->edittree, type);
+       }
        BLI_assert(node && node->typeinfo);
 
        /* Position mouse in node header. */
@@ -128,8 +130,9 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket
        copy_v2_v2(socklink->point, point);
 
        for (prev = lb->last; prev; prev = prev->prev) {
-               if (prev->sock == sock)
+               if (prev->sock == sock) {
                        break;
+               }
        }
        BLI_insertlinkafter(lb, prev, socklink);
        return socklink;
@@ -208,7 +211,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
                UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1],
                                         &mcoords[i][0], &mcoords[i][1]);
                i++;
-               if (i >= 256) break;
+               if (i >= 256) {
+                       break;
+               }
        }
        RNA_END;
 
@@ -228,8 +233,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
                BLI_listbase_clear(&input_links);
 
                for (link = ntree->links.first; link; link = link->next) {
-                       if (nodeLinkIsHidden(link))
+                       if (nodeLinkIsHidden(link)) {
                                continue;
+                       }
                        if (add_reroute_intersect_check(link, mcoords, i, insert_point)) {
                                add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point);
                                add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point);
@@ -356,10 +362,12 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
        snode->cursor[0] /= UI_DPI_FAC;
        snode->cursor[1] /= UI_DPI_FAC;
 
-       if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name"))
+       if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) {
                return node_add_file_exec(C, op);
-       else
+       }
+       else {
                return WM_operator_filesel(C, op, event);
+       }
 }
 
 void NODE_OT_add_file(wmOperatorType *ot)
@@ -460,10 +468,12 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
                prop = RNA_struct_find_property(op->ptr, "type");
                RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname);
        }
-       else if (snode)
+       else if (snode) {
                idname = snode->tree_idname;
-       else
+       }
+       else {
                return OPERATOR_CANCELLED;
+       }
 
        if (RNA_struct_property_is_set(op->ptr, "name")) {
                RNA_string_get(op->ptr, "name", treename_buf);
index da0be28..13f8eb0 100644 (file)
@@ -76,8 +76,9 @@ static void node_sockets_panel(const bContext *C, Panel *pa)
        uiLayout *layout = pa->layout, *split;
        char name[UI_MAX_NAME_STR];
 
-       if (ELEM(NULL, ntree, node))
+       if (ELEM(NULL, ntree, node)) {
                return;
+       }
 
        for (sock = node->inputs.first; sock; sock = sock->next) {
                BLI_snprintf(name, sizeof(name), "%s:", sock->name);
@@ -128,8 +129,9 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
        PointerRNA ptr, sockptr, opptr;
        wmOperatorType *ot;
 
-       if (!ntree)
+       if (!ntree) {
                return;
+       }
 
        RNA_id_pointer_create((ID *)ntree, &ptr);
 
@@ -204,8 +206,9 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = node_has_buttons_region(sa);
 
-       if (ar)
+       if (ar) {
                ED_region_toggle_hidden(C, ar);
+       }
 
        return OPERATOR_FINISHED;
 }
index afef027..2d25c06 100644 (file)
@@ -120,8 +120,9 @@ static bNodeTree *node_tree_from_ID(ID *id)
 void ED_node_tag_update_id(ID *id)
 {
        bNodeTree *ntree = node_tree_from_ID(id);
-       if (id == NULL || ntree == NULL)
+       if (id == NULL || ntree == NULL) {
                return;
+       }
 
        /* TODO(sergey): With the new dependency graph it
         * should be just enough to only tag ntree itself,
@@ -133,12 +134,15 @@ void ED_node_tag_update_id(ID *id)
        if (ntree->type == NTREE_SHADER) {
                DEG_id_tag_update(id, 0);
 
-               if (GS(id->name) == ID_MA)
+               if (GS(id->name) == ID_MA) {
                        WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
-               else if (GS(id->name) == ID_LA)
+               }
+               else if (GS(id->name) == ID_LA) {
                        WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
-               else if (GS(id->name) == ID_WO)
+               }
+               else if (GS(id->name) == ID_WO) {
                        WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
+               }
        }
        else if (ntree->type == NTREE_COMPOSIT) {
                WM_main_add_notifier(NC_SCENE | ND_NODES, id);
@@ -155,8 +159,9 @@ void ED_node_tag_update_id(ID *id)
 
 void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
 {
-       if (!ntree)
+       if (!ntree) {
                return;
+       }
 
        bool do_tag_update = true;
        if (node != NULL) {
@@ -169,13 +174,15 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
        if (do_tag_update) {
                FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
                        /* check if nodetree uses the group */
-                       if (ntreeHasTree(tntree, ntree))
+                       if (ntreeHasTree(tntree, ntree)) {
                                ED_node_tag_update_id(id);
+                       }
                } FOREACH_NODETREE_END;
        }
 
-       if (ntree->type == NTREE_TEXTURE)
+       if (ntree->type == NTREE_TEXTURE) {
                ntreeTexCheckCyclics(ntree);
+       }
 }
 
 static bool compare_nodes(const bNode *a, const bNode *b)
@@ -192,36 +199,46 @@ static bool compare_nodes(const bNode *a, const bNode *b)
         * this is O(n^2) worst case */
        for (parent = a->parent; parent; parent = parent->parent) {
                /* if b is an ancestor, it is always behind a */
-               if (parent == b)
+               if (parent == b) {
                        return 1;
+               }
                /* any selected ancestor moves the node forward */
-               if (parent->flag & NODE_ACTIVE)
+               if (parent->flag & NODE_ACTIVE) {
                        a_active = 1;
-               if (parent->flag & NODE_SELECT)
+               }
+               if (parent->flag & NODE_SELECT) {
                        a_select = 1;
+               }
        }
        for (parent = b->parent; parent; parent = parent->parent) {
                /* if a is an ancestor, it is always behind b */
-               if (parent == a)
+               if (parent == a) {
                        return 0;
+               }
                /* any selected ancestor moves the node forward */
-               if (parent->flag & NODE_ACTIVE)
+               if (parent->flag & NODE_ACTIVE) {
                        b_active = 1;
-               if (parent->flag & NODE_SELECT)
+               }
+               if (parent->flag & NODE_SELECT) {
                        b_select = 1;
+               }
        }
 
        /* if one of the nodes is in the background and the other not */
-       if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND))
+       if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) {
                return 0;
-       else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
+       }
+       else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) {
                return 1;
+       }
 
        /* if one has a higher selection state (active > selected > nothing) */
-       if (!b_active && a_active)
+       if (!b_active && a_active) {
                return 1;
-       else if (!b_select && (a_active || a_select))
+       }
+       else if (!b_select && (a_active || a_select)) {
                return 1;
+       }
 
        return 0;
 }
@@ -246,8 +263,9 @@ void ED_node_sort(bNodeTree *ntree)
                                first_b = first_b->next;
                        }
                        /* all batches merged? */
-                       if (first_b == NULL)
+                       if (first_b == NULL) {
                                break;
+                       }
 
                        /* merge batches */
                        node_a = first_a;
@@ -271,8 +289,9 @@ void ED_node_sort(bNodeTree *ntree)
                        first_b = node_b;
                        for (; b < k; ++b) {
                                /* all nodes sorted? */
-                               if (first_b == NULL)
+                               if (first_b == NULL) {
                                        break;
+                               }
                                first_b = first_b->next;
                        }
                        first_a = first_b;
@@ -287,8 +306,9 @@ static void do_node_internal_buttons(bContext *C, void *UNUSED(node_v), int even
 {
        if (event == B_NODE_EXEC) {
                SpaceNode *snode = CTX_wm_space_node(C);
-               if (snode && snode->id)
+               if (snode && snode->id) {
                        ED_node_tag_update_id(snode->id);
+               }
        }
 }
 
@@ -351,15 +371,17 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
        dy -= NODE_DY;
 
        /* little bit space in top */
-       if (node->outputs.first)
+       if (node->outputs.first) {
                dy -= NODE_DYS / 2;
+       }
 
        /* output sockets */
        bool add_output_space = false;
 
        for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
-               if (nodeSocketIsHidden(nsock))
+               if (nodeSocketIsHidden(nsock)) {
                        continue;
+               }
 
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
 
@@ -387,8 +409,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                nsock->locy = 0.5f * (dy + buty);
 
                dy = buty;
-               if (nsock->next)
+               if (nsock->next) {
                        dy -= NODE_SOCKDY;
+               }
 
                add_output_space = true;
        }
@@ -404,14 +427,16 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
        if (node->flag & NODE_PREVIEW) {
                float aspect = 1.0f;
 
-               if (node->preview_xsize && node->preview_ysize)
+               if (node->preview_xsize && node->preview_ysize) {
                        aspect = (float)node->preview_ysize / (float)node->preview_xsize;
+               }
 
                dy -= NODE_DYS / 2;
                node->prvr.ymax = dy;
 
-               if (aspect <= 1.0f)
+               if (aspect <= 1.0f) {
                        node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
+               }
                else {
                        /* width correction of image */
                        /* XXX huh? (ton) */
@@ -426,8 +451,12 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                dy = node->prvr.ymin - NODE_DYS / 2;
 
                /* make sure that maximums are bigger or equal to minimums */
-               if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin);
-               if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
+               if (node->prvr.xmax < node->prvr.xmin) {
+                       SWAP(float, node->prvr.xmax, node->prvr.xmin);
+               }
+               if (node->prvr.ymax < node->prvr.ymin) {
+                       SWAP(float, node->prvr.ymax, node->prvr.ymin);
+               }
        }
 
        /* buttons rect? */
@@ -456,8 +485,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
 
        /* input sockets */
        for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
-               if (nodeSocketIsHidden(nsock))
+               if (nodeSocketIsHidden(nsock)) {
                        continue;
+               }
 
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
 
@@ -483,13 +513,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                nsock->locy = 0.5f * (dy + buty);
 
                dy = buty;
-               if (nsock->next)
+               if (nsock->next) {
                        dy -= NODE_SOCKDY;
+               }
        }
 
        /* little bit space in end */
-       if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0)
+       if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) {
                dy -= NODE_DYS / 2;
+       }
 
        node->totr.xmin = locx;
        node->totr.xmax = locx + NODE_WIDTH(node);
@@ -519,12 +551,16 @@ static void node_update_hidden(bNode *node)
        node_to_view(node, 0.0f, 0.0f, &locx, &locy);
 
        /* calculate minimal radius */
-       for (nsock = node->inputs.first; nsock; nsock = nsock->next)
-               if (!nodeSocketIsHidden(nsock))
+       for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
+               if (!nodeSocketIsHidden(nsock)) {
                        totin++;
-       for (nsock = node->outputs.first; nsock; nsock = nsock->next)
-               if (!nodeSocketIsHidden(nsock))
+               }
+       }
+       for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
+               if (!nodeSocketIsHidden(nsock)) {
                        totout++;
+               }
+       }
 
        tot = MAX2(totin, totout);
        if (tot > 4) {
@@ -571,10 +607,12 @@ static void node_update_hidden(bNode *node)
 
 void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node)
 {
-       if (node->flag & NODE_HIDDEN)
+       if (node->flag & NODE_HIDDEN) {
                node_update_hidden(node);
-       else
+       }
+       else {
                node_update_basis(C, ntree, node);
+       }
 }
 
 int node_select_area_default(bNode *node, int x, int y)
@@ -618,8 +656,9 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
 
        GPU_blend(true);
 
-       for (link = node->internal_links.first; link; link = link->next)
+       for (link = node->internal_links.first; link; link = link->next) {
                node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1);
+       }
 
        GPU_blend(false);
 }
@@ -656,10 +695,12 @@ static void node_draw_preview_background(float tile, rctf *rect)
                for (x = rect->xmin; x < rect->xmax; x += tile * 2) {
                        float tilex = tile, tiley = tile;
 
-                       if (x + tile > rect->xmax)
+                       if (x + tile > rect->xmax) {
                                tilex = rect->xmax - x;
-                       if (y + tile > rect->ymax)
+                       }
+                       if (y + tile > rect->ymax) {
                                tiley = rect->ymax - y;
+                       }
 
                        immRectf(pos, x, y, x + tilex, y + tiley);
                }
@@ -668,10 +709,12 @@ static void node_draw_preview_background(float tile, rctf *rect)
                for (x = rect->xmin + tile; x < rect->xmax; x += tile * 2) {
                        float tilex = tile, tiley = tile;
 
-                       if (x + tile > rect->xmax)
+                       if (x + tile > rect->xmax) {
                                tilex = rect->xmax - x;
-                       if (y + tile > rect->ymax)
+                       }
+                       if (y + tile > rect->ymax) {
                                tiley = rect->ymax - y;
+                       }
 
                        immRectf(pos, x, y, x + tilex, y + tiley);
                }
@@ -740,8 +783,9 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
        rctf *rct = &node->totr;
 
        UI_draw_roundbox_corner_set(UI_CNR_ALL);
-       if (node->parent == NULL)
+       if (node->parent == NULL) {
                ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT);
+       }
        else {
                const float margin = 3.0f;
 
@@ -790,8 +834,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
        short selected_input_len = 0;
        bNodeSocket *sock;
        for (sock = node->inputs.first; sock; sock = sock->next) {
-               if (nodeSocketIsHidden(sock))
+               if (nodeSocketIsHidden(sock)) {
                        continue;
+               }
                if (select_all || (sock->flag & SELECT)) {
                        ++selected_input_len;
                        continue;
@@ -804,8 +849,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
        short selected_output_len = 0;
        if (draw_outputs) {
                for (sock = node->outputs.first; sock; sock = sock->next) {
-                       if (nodeSocketIsHidden(sock))
+                       if (nodeSocketIsHidden(sock)) {
                                continue;
+                       }
                        if (select_all || (sock->flag & SELECT)) {
                                ++selected_output_len;
                                continue;
@@ -832,12 +878,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
                if (selected_input_len) {
                        /* socket inputs */
                        for (sock = node->inputs.first; sock; sock = sock->next) {
-                               if (nodeSocketIsHidden(sock))
+                               if (nodeSocketIsHidden(sock)) {
                                        continue;
+                               }
                                if (select_all || (sock->flag & SELECT)) {
                                        node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
-                                       if (--selected_input_len == 0)
+                                       if (--selected_input_len == 0) {
                                                break; /* stop as soon as last one is drawn */
+                                       }
                                }
                        }
                }
@@ -845,12 +893,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
                if (selected_output_len) {
                        /* socket outputs */
                        for (sock = node->outputs.first; sock; sock = sock->next) {
-                               if (nodeSocketIsHidden(sock))
+                               if (nodeSocketIsHidden(sock)) {
                                        continue;
+                               }
                                if (select_all || (sock->flag & SELECT)) {
                                        node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
-                                       if (--selected_output_len == 0)
+                                       if (--selected_output_len == 0) {
                                                break; /* stop as soon as last one is drawn */
+                                       }
                                }
                        }
                }
@@ -979,8 +1029,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        else if (node->flag & NODE_CUSTOM_COLOR) {
                rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], 1.0f);
        }
-       else
+       else {
                UI_GetThemeColor4fv(TH_NODE, color);
+       }
 
        UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT);
        UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD, color);
@@ -994,8 +1045,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        }
 
        /* disable lines */
-       if (node->flag & NODE_MUTED)
+       if (node->flag & NODE_MUTED) {
                node_draw_mute_line(v2d, snode, node);
+       }
 
        node_draw_sockets(v2d, C, ntree, node, true, false);
 
@@ -1033,10 +1085,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
        node_draw_shadow(snode, node, hiddenrad, 1.0f);
 
        /* body */
-       if (node->flag & NODE_MUTED)
+       if (node->flag & NODE_MUTED) {
                UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
-       else
+       }
+       else {
                UI_GetThemeColor4fv(color_id, color);
+       }
 
        UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color);
 
@@ -1084,8 +1138,9 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
        }
 
        /* disable lines */
-       if (node->flag & NODE_MUTED)
+       if (node->flag & NODE_MUTED) {
                node_draw_mute_line(&ar->v2d, snode, node);
+       }
 
        if (node->miniwidth > 0.0f) {
                nodeLabel(ntree, node, showname, sizeof(showname));
@@ -1137,14 +1192,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
 
 int node_get_resize_cursor(int directions)
 {
-       if (directions == 0)
+       if (directions == 0) {
                return CURSOR_STD;
-       else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0)
+       }
+       else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) {
                return CURSOR_Y_MOVE;
-       else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0)
+       }
+       else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) {
                return CURSOR_X_MOVE;
-       else
+       }
+       else {
                return CURSOR_EDIT;
+       }
 }
 
 void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
@@ -1161,8 +1220,9 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
                else {
                        /* check nodes front to back */
                        for (node = ntree->nodes.last; node; node = node->prev) {
-                               if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1]))
+                               if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) {
                                        break;  /* first hit on node stops */
+                               }
                        }
                        if (node) {
                                int dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
@@ -1176,16 +1236,19 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
 
 void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
 {
-       if (node->flag & NODE_HIDDEN)
+       if (node->flag & NODE_HIDDEN) {
                node_draw_hidden(C, ar, snode, ntree, node, key);
-       else
+       }
+       else {
                node_draw_basis(C, ar, snode, ntree, node, key);
+       }
 }
 
 static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
 {
-       if (node->typeinfo->draw_nodetype_prepare)
+       if (node->typeinfo->draw_nodetype_prepare) {
                node->typeinfo->draw_nodetype_prepare(C, ntree, node);
+       }
 }
 
 void node_update_nodetree(const bContext *C, bNodeTree *ntree)
@@ -1203,8 +1266,9 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree)
 
 static void node_draw(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
 {
-       if (node->typeinfo->draw_nodetype)
+       if (node->typeinfo->draw_nodetype) {
                node->typeinfo->draw_nodetype(C, ar, snode, ntree, node, key);
+       }
 }
 
 #define USE_DRAW_TOT_UPDATE
@@ -1215,7 +1279,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
        bNodeLink *link;
        int a;
 
-       if (ntree == NULL) return;      /* groups... */
+       if (ntree == NULL) {
+               return;      /* groups... */
+       }
 
 #ifdef USE_DRAW_TOT_UPDATE
        if (ntree->nodes.first) {
@@ -1233,8 +1299,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
                BLI_rctf_union(&ar->v2d.tot, &node->totr);
 #endif
 
-               if (!(node->flag & NODE_BACKGROUND))
+               if (!(node->flag & NODE_BACKGROUND)) {
                        continue;
+               }
 
                key = BKE_node_instance_key(parent_key, ntree, node);
                node->nr = a;        /* index of node in list, used for exec event code */
@@ -1245,8 +1312,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
        GPU_blend(true);
        nodelink_batch_start(snode);
        for (link = ntree->links.first; link; link = link->next) {
-               if (!nodeLinkIsHidden(link))
+               if (!nodeLinkIsHidden(link)) {
                        node_draw_link(&ar->v2d, snode, link);
+               }
        }
        nodelink_batch_end(snode);
        GPU_blend(false);
@@ -1254,8 +1322,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
        /* draw foreground nodes, last nodes in front */
        for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) {
                bNodeInstanceKey key;
-               if (node->flag & NODE_BACKGROUND)
+               if (node->flag & NODE_BACKGROUND) {
                        continue;
+               }
 
                key = BKE_node_instance_key(parent_key, ntree, node);
                node->nr = a;        /* index of node in list, used for exec event code */
@@ -1370,8 +1439,9 @@ void drawnodespace(const bContext *C, ARegion *ar)
 
                /* store new view center in path and current edittree */
                copy_v2_v2(path->view_center, center);
-               if (snode->edittree)
+               if (snode->edittree) {
                        copy_v2_v2(snode->edittree->view_center, center);
+               }
 
                depth = 0;
                while (path->prev && depth < max_depth) {
@@ -1424,8 +1494,9 @@ void drawnodespace(const bContext *C, ARegion *ar)
                GPU_blend(true);
                GPU_line_smooth(true);
                for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) {
-                       for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next)
+                       for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
                                node_draw_link(v2d, snode, (bNodeLink *)linkdata->data);
+                       }
                }
                GPU_line_smooth(false);
                GPU_blend(false);
index eb20f4e..0c7b3da 100644 (file)
@@ -97,16 +97,19 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
 
        for (node = nodetree->nodes.first; node; node = node->next) {
                if (node->type == CMP_NODE_COMPOSITE) {
-                       if (recalc_flags & COM_RECALC_COMPOSITE)
+                       if (recalc_flags & COM_RECALC_COMPOSITE) {
                                node->flag |= NODE_DO_OUTPUT_RECALC;
+                       }
                }
                else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) {
-                       if (recalc_flags & COM_RECALC_VIEWER)
+                       if (recalc_flags & COM_RECALC_VIEWER) {
                                node->flag |= NODE_DO_OUTPUT_RECALC;
+                       }
                }
                else if (node->type == NODE_GROUP) {
-                       if (node->id)
+                       if (node->id) {
                                compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags);
+                       }
                }
        }
 }
@@ -125,16 +128,19 @@ static int compo_get_recalc_flags(const bContext *C)
                        if (sa->spacetype == SPACE_IMAGE) {
                                SpaceImage *sima = sa->spacedata.first;
                                if (sima->image) {
-                                       if (sima->image->type == IMA_TYPE_R_RESULT)
+                                       if (sima->image->type == IMA_TYPE_R_RESULT) {
                                                recalc_flags |= COM_RECALC_COMPOSITE;
-                                       else if (sima->image->type == IMA_TYPE_COMPOSITE)
+                                       }
+                                       else if (sima->image->type == IMA_TYPE_COMPOSITE) {
                                                recalc_flags |= COM_RECALC_VIEWER;
+                                       }
                                }
                        }
                        else if (sa->spacetype == SPACE_NODE) {
                                SpaceNode *snode = sa->spacedata.first;
-                               if (snode->flag & SNODE_BACKDRAW)
+                               if (snode->flag & SNODE_BACKDRAW) {
                                        recalc_flags |= COM_RECALC_VIEWER;
+                               }
                        }
                }
        }
@@ -190,8 +196,9 @@ static void compo_initjob(void *cjv)
 
        cj->localtree = ntreeLocalize(cj->ntree);
 
-       if (cj->recalc_flags)
+       if (cj->recalc_flags) {
                compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
+       }
 }
 
 /* called before redraw notifiers, it moves finished previews over */
@@ -215,8 +222,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
        Scene *scene = cj->scene;
        SceneRenderView *srv;
 
-       if (scene->use_nodes == false)
+       if (scene->use_nodes == false) {
                return;
+       }
 
        cj->stop = stop;
        cj->do_update = do_update;
@@ -239,7 +247,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
        }
        else {
                for (srv = scene->r.views.first; srv; srv = srv->next) {
-                       if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) continue;
+                       if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) {
+                               continue;
+                       }
                        ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings, srv->name);
                }
        }
@@ -300,8 +310,9 @@ bool composite_node_active(bContext *C)
 {
        if (ED_operator_node_active(C)) {
                SpaceNode *snode = CTX_wm_space_node(C);
-               if (ED_node_is_compositor(snode))
+               if (ED_node_is_compositor(snode)) {
                        return 1;
+               }
        }
        return 0;
 }
@@ -311,8 +322,9 @@ bool composite_node_editable(bContext *C)
 {
        if (ED_operator_node_editable(C)) {
                SpaceNode *snode = CTX_wm_space_node(C);
-               if (ED_node_is_compositor(snode))
+               if (ED_node_is_compositor(snode)) {
                        return 1;
+               }
        }
        return 0;
 }
@@ -324,8 +336,9 @@ void snode_dag_update(bContext *C, SpaceNode *snode)
        /* for groups, update all ID's using this */
        if (snode->edittree != snode->nodetree) {
                FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
-                       if (ntreeHasTree(tntree, snode->edittree))
+                       if (ntreeHasTree(tntree, snode->edittree)) {
                                DEG_id_tag_update(id, 0);
+                       }
                } FOREACH_NODETREE_END;
        }
 
@@ -339,25 +352,32 @@ void snode_notify(bContext *C, SpaceNode *snode)
        WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL);
 
        if (ED_node_is_shader(snode)) {
-               if (GS(id->name) == ID_MA)
+               if (GS(id->name) == ID_MA) {
                        WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
-               else if (GS(id->name) == ID_LA)
+               }
+               else if (GS(id->name) == ID_LA) {
                        WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
-               else if (GS(id->name) == ID_WO)
+               }
+               else if (GS(id->name) == ID_WO) {
                        WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
+               }
        }
-       else if (ED_node_is_compositor(snode))
+       else if (ED_node_is_compositor(snode)) {
                WM_event_add_notifier(C, NC_SCENE | ND_NODES, id);
-       else if (ED_node_is_texture(snode))
+       }
+       else if (ED_node_is_texture(snode)) {
                WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, id);
+       }
 }
 
 void ED_node_set_tree_type(SpaceNode *snode, bNodeTreeType *typeinfo)
 {
-       if (typeinfo)
+       if (typeinfo) {
                BLI_strncpy(snode->tree_idname, typeinfo->idname, sizeof(snode->tree_idname));
-       else
+       }
+       else {
                snode->tree_idname[0] = '\0';
+       }
 }
 
 bool ED_node_is_compositor(struct SpaceNode *snode)
@@ -421,10 +441,12 @@ void ED_node_shader_default(const bContext *C, ID *id)
                        shader_type = SH_NODE_EMISSION;
 
                        copy_v3_v3(color, &la->r);
-                       if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA)
+                       if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) {
                                strength = 100.0f;
-                       else
+                       }
+                       else {
                                strength = 1.0f;
+                       }
                        break;
                }
                default:
@@ -469,8 +491,9 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
 
        /* but lets check it anyway */
        if (sce->nodetree) {
-               if (G.debug & G_DEBUG)
+               if (G.debug & G_DEBUG) {
                        printf("error in composite initialize\n");
+               }
                return;
        }
 
@@ -504,8 +527,9 @@ void ED_node_texture_default(const bContext *C, Tex *tx)
 
        /* but lets check it anyway */
        if (tx->nodetree) {
-               if (G.debug & G_DEBUG)
+               if (G.debug & G_DEBUG) {
                        printf("error in texture initialize\n");
+               }
                return;
        }
 
@@ -588,8 +612,9 @@ void snode_update(SpaceNode *snode, bNode *node)
                }
        }
 
-       if (node)
+       if (node) {
                nodeUpdate(snode->edittree, node);
+       }
 }
 
 void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
@@ -605,49 +630,61 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
                /* generic node group output: set node as active output */
                if (node->type == NODE_GROUP_OUTPUT) {
                        bNode *tnode;
-                       for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
-                               if (tnode->type == NODE_GROUP_OUTPUT)
+                       for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+                               if (tnode->type == NODE_GROUP_OUTPUT) {
                                        tnode->flag &= ~NODE_DO_OUTPUT;
+                               }
+                       }
 
                        node->flag |= NODE_DO_OUTPUT;
-                       if (!was_output)
+                       if (!was_output) {
                                do_update = 1;
+                       }
                }
 
                /* tree specific activate calls */
                if (ntree->type == NTREE_SHADER) {
                        /* when we select a material, active texture is cleared, for buttons */
-                       if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO))
+                       if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) {
                                nodeClearActiveID(ntree, ID_TE);
+                       }
 
                        if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
                                 SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE))
                        {
                                bNode *tnode;
 
-                               for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
-                                       if (tnode->type == node->type)
+                               for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+                                       if (tnode->type == node->type) {
                                                tnode->flag &= ~NODE_DO_OUTPUT;
+                                       }
+                               }
 
                                node->flag |= NODE_DO_OUTPUT;
-                               if (was_output == 0)
+                               if (was_output == 0) {
                                        ED_node_tag_update_nodetree(bmain, ntree, node);
+                               }
                        }
-                       else if (do_update)
+                       else if (do_update) {
                                ED_node_tag_update_nodetree(bmain, ntree, node);
+                       }
 
                        /* if active texture changed, free glsl materials */
                        if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) {
                                Material *ma;
                                World *wo;
 
-                               for (ma = bmain->materials.first; ma; ma = ma->id.next)
-                                       if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree))
+                               for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+                                       if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) {
                                                GPU_material_free(&ma->gpumaterial);
+                                       }
+                               }
 
-                               for (wo = bmain->worlds.first; wo; wo = wo->id.next)
-                                       if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree))
+                               for (wo = bmain->worlds.first; wo; wo = wo->id.next) {
+                                       if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) {
                                                GPU_material_free(&wo->gpumaterial);
+                                       }
+                               }
 
                                ED_node_tag_update_nodetree(bmain, ntree, node);
                                WM_main_add_notifier(NC_IMAGE, NULL);
@@ -661,13 +698,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
                                bNode *tnode;
 
 
-                               for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
-                                       if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
+                               for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+                                       if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
                                                tnode->flag &= ~NODE_DO_OUTPUT;
+                                       }
+                               }
 
                                node->flag |= NODE_DO_OUTPUT;
-                               if (was_output == 0)
+                               if (was_output == 0) {
                                        ED_node_tag_update_nodetree(bmain, ntree, node);
+                               }
 
                                /* addnode() doesn't link this yet... */
                                node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
@@ -676,16 +716,19 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
                                if (was_output == 0) {
                                        bNode *tnode;
 
-                                       for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
-                                               if (tnode->type == CMP_NODE_COMPOSITE)
+                                       for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+                                               if (tnode->type == CMP_NODE_COMPOSITE) {
                                                        tnode->flag &= ~NODE_DO_OUTPUT;
+                                               }
+                                       }
 
                                        node->flag |= NODE_DO_OUTPUT;
                                        ED_node_tag_update_nodetree(bmain, ntree, node);
                                }
                        }
-                       else if (do_update)
+                       else if (do_update) {
                                ED_node_tag_update_nodetree(bmain, ntree, node);
+                       }
                }
                else if (ntree->type == NTREE_TEXTURE) {
                        // XXX
@@ -780,8 +823,9 @@ static bNode *visible_node(SpaceNode *snode, const rctf *rct)
        bNode *node;
 
        for (node = snode->edittree->nodes.last; node; node = node->prev) {
-               if (BLI_rctf_isect(&node->totr, rct, NULL))
+               if (BLI_rctf_isect(&node->totr, rct, NULL)) {
                        break;
+               }
        }
        return node;
 }
@@ -986,12 +1030,16 @@ int node_has_hidden_sockets(bNode *node)
 {
        bNodeSocket *sock;
 
-       for (sock = node->inputs.first; sock; sock = sock->next)
-               if (sock->flag & SOCK_HIDDEN)
+       for (sock = node->inputs.first; sock; sock = sock->next) {
+               if (sock->flag & SOCK_HIDDEN) {
                        return 1;
-       for (sock = node->outputs.first; sock; sock = sock->next)
-               if (sock->flag & SOCK_HIDDEN)
+               }
+       }
+       for (sock = node->outputs.first; sock; sock = sock->next) {
+               if (sock->flag & SOCK_HIDDEN) {
                        return 1;
+               }
+       }
        return 0;
 }
 
@@ -1000,20 +1048,24 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
        bNodeSocket *sock;
 
        if (set == 0) {
-               for (sock = node->inputs.first; sock; sock = sock->next)
+               for (sock = node->inputs.first; sock; sock = sock->next) {
                        sock->flag &= ~SOCK_HIDDEN;
-               for (sock = node->outputs.first; sock; sock = sock->next)
+               }
+               for (sock = node->outputs.first; sock; sock = sock->next) {
                        sock->flag &= ~SOCK_HIDDEN;
+               }
        }
        else {
                /* hide unused sockets */
                for (sock = node->inputs.first; sock; sock = sock->next) {
-                       if (sock->link == NULL)
+                       if (sock->link == NULL) {
                                sock->flag |= SOCK_HIDDEN;
+                       }
                }
                for (sock = node->outputs.first; sock; sock = sock->next) {
-                       if (nodeCountSocketLinks(snode->edittree, sock) == 0)
+                       if (nodeCountSocketLinks(snode->edittree, sock) == 0) {
                                sock->flag |= SOCK_HIDDEN;
+                       }
                }
        }
 }
@@ -1089,8 +1141,9 @@ static void node_duplicate_reparent_recursive(bNode *node)
        /* find first selected parent */
        for (parent = node->parent; parent; parent = parent->parent) {
                if (parent->flag & SELECT) {
-                       if (!(parent->flag & NODE_TEST))
+                       if (!(parent->flag & NODE_TEST)) {
                                node_duplicate_reparent_recursive(parent);
+                       }
                        break;
                }
        }
@@ -1123,8 +1176,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
                }
 
                /* make sure we don't copy new nodes again! */
-               if (node == lastnode)
+               if (node == lastnode) {
                        break;
+               }
        }
 
        /* copy links between selected nodes
@@ -1156,21 +1210,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
                }
 
                /* make sure we don't copy new links again! */
-               if (link == lastlink)
+               if (link == lastlink) {
                        break;
+               }
        }
 
        /* clear flags for recursive depth-first iteration */
-       for (node = ntree->nodes.first; node; node = node->next)
+       for (node = ntree->nodes.first; node; node = node->next) {
                node->flag &= ~NODE_TEST;
+       }
        /* reparent copied nodes */
        for (node = ntree->nodes.first; node; node = node->next) {
-               if ((node->flag & SELECT) && !(node->flag & NODE_TEST))
+               if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) {
                        node_duplicate_reparent_recursive(node);
+               }
 
                /* only has to check old nodes */
-               if (node == lastnode)
+               if (node == lastnode) {
                        break;
+               }
        }
 
        /* deselect old nodes, select the copies instead */
@@ -1187,8 +1245,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
                }
 
                /* make sure we don't copy new nodes again! */
-               if (node == lastnode)
+               if (node == lastnode) {
                        break;
+               }
        }
 
        ntreeUpdateTree(CTX_data_main(C), snode->edittree);
@@ -1232,10 +1291,12 @@ bool ED_node_select_check(ListBase *lb)
 void ED_node_select_all(ListBase *lb, int action)
 {
        if (action == SEL_TOGGLE) {
-               if (ED_node_select_check(lb))
+               if (ED_node_select_check(lb)) {
                        action = SEL_DESELECT;
-               else
+               }
+               else {
                        action = SEL_SELECT;
+               }
        }
 
        for (bNode *node = lb->first; node; node = node->next) {
@@ -1268,8 +1329,9 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
        ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
 
        /* first tag scenes unread */
-       for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+       for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
                scene->id.tag |= LIB_TAG_DOIT;
+       }
 
        for (node = snode->edittree->nodes.first; node; node = node->next) {
                if (node->type == CMP_NODE_R_LAYERS) {
@@ -1365,29 +1427,37 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
        for (node = snode->edittree->nodes.first; node; node = node->next) {
                if (node->flag & SELECT) {
 
-                       if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
+                       if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
                                continue;
-                       if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
+                       }
+                       if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
                                continue;
+                       }
 
-                       if (node->flag & toggle_flag)
+                       if (node->flag & toggle_flag) {
                                tot_eq++;
-                       else
+                       }
+                       else {
                                tot_neq++;
+                       }
                }
        }
        for (node = snode->edittree->nodes.first; node; node = node->next) {
                if (node->flag & SELECT) {
 
-                       if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
+                       if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
                                continue;
-                       if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
+                       }
+                       if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
                                continue;
+                       }
 
-                       if ((tot_eq && tot_neq) || tot_eq == 0)
+                       if ((tot_eq && tot_neq) || tot_eq == 0) {
                                node->flag |= toggle_flag;
-                       else
+                       }
+                       else {
                                node->flag &= ~toggle_flag;
+                       }
                }
        }
 }
@@ -1397,8 +1467,9 @@ static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceNode *snode = CTX_wm_space_node(C);
 
        /* sanity checking (poll callback checks this already) */
-       if ((snode == NULL) || (snode->edittree == NULL))
+       if ((snode == NULL) || (snode->edittree == NULL)) {
                return OPERATOR_CANCELLED;
+       }
 
        node_flag_toggle_exec(snode, NODE_HIDDEN);
 
@@ -1427,8 +1498,9 @@ static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceNode *snode = CTX_wm_space_node(C);
 
        /* sanity checking (poll callback checks this already) */
-       if ((snode == NULL) || (snode->edittree == NULL))
+       if ((snode == NULL) || (snode->edittree == NULL)) {
                return OPERATOR_CANCELLED;
+       }
 
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
@@ -1459,8 +1531,9 @@ static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceNode *snode = CTX_wm_space_node(C);
 
        /* sanity checking (poll callback checks this already) */
-       if ((snode == NULL) || (snode->edittree == NULL))
+       if ((snode == NULL) || (snode->edittree == NULL)) {
                return OPERATOR_CANCELLED;
+       }
 
        node_flag_toggle_exec(snode, NODE_OPTIONS);
 
@@ -1491,8 +1564,9 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        int hidden;
 
        /* sanity checking (poll callback checks this already) */
-       if ((snode == NULL) || (snode->edittree == NULL))
+       if ((snode == NULL) || (snode->edittree == NULL)) {
                return OPERATOR_CANCELLED;
+       }
 
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
@@ -1628,8 +1702,9 @@ static bool node_switch_view_poll(bContext *C)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
 
-       if (snode && snode->edittree)
+       if (snode && snode->edittree) {
                return true;
+       }
 
        return false;
 }
@@ -1731,8 +1806,9 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
                node = nodeGetActive(snode->edittree);
        }
 
-       if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+       if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
                return OPERATOR_CANCELLED;
+       }
 
        RNA_string_get(op->ptr, "file_path", file_path);
        ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format);
@@ -1777,11 +1853,13 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
                node = nodeGetActive(snode->edittree);
        }
 
-       if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+       if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
                return OPERATOR_CANCELLED;
+       }
 
-       if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node))
+       if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) {
                return OPERATOR_CANCELLED;
+       }
 
        snode_notify(C, snode);
 
@@ -1814,34 +1892,40 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
        bNodeSocket *sock;
        int direction;
 
-       if (ptr.data)
+       if (ptr.data) {
                node = ptr.data;
-       else if (snode && snode->edittree)
+       }
+       else if (snode && snode->edittree) {
                node = nodeGetActive(snode->edittree);
+       }
 
-       if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+       if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
                return OPERATOR_CANCELLED;
+       }
 
        nimf = node->storage;
 
        sock = BLI_findlink(&node->inputs, nimf->active_input);
-       if (!sock)
+       if (!sock) {
                return OPERATOR_CANCELLED;
+       }
 
        direction = RNA_enum_get(op->ptr, "direction");
 
        if (direction == 1) {
                bNodeSocket *before = sock->prev;
-               if (!before)
+               if (!before) {
                        return OPERATOR_CANCELLED;
+               }
                BLI_remlink(&node->inputs, sock);
                BLI_insertlinkbefore(&node->inputs, before, sock);
                nimf->active_input--;
        }
        else {
                bNodeSocket *after = sock->next;
-               if (!after)
+               if (!after) {
                        return OPERATOR_CANCELLED;
+               }
                BLI_remlink(&node->inputs, sock);
                BLI_insertlinkafter(&node->inputs, after, sock);
                nimf->active_input++;
@@ -1883,11 +1967,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
        bNodeTree *ntree = snode->edittree;
        bNode *node, *tnode;
 
-       if (!ntree)
+       if (!ntree) {
                return OPERATOR_CANCELLED;
+       }
        node = nodeGetActive(ntree);
-       if (!node)
+       if (!node) {
                return OPERATOR_CANCELLED;
+       }
 
        for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
                if (tnode->flag & NODE_SELECT && tnode != node) {
@@ -1895,8 +1981,9 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
                                tnode->flag |= NODE_CUSTOM_COLOR;
                                copy_v3_v3(tnode->color, node->color);
                        }
-                       else
+                       else {
                                tnode->flag &= ~NODE_CUSTOM_COLOR;
+                       }
                }
        }
 
@@ -2041,8 +2128,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
                        BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name + 2);
                }
        }
-       if (!all_nodes_valid)
+       if (!all_nodes_valid) {
                return OPERATOR_CANCELLED;
+       }
 
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
@@ -2068,8 +2156,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
        /* reparent copied nodes */
        for (node = clipboard_nodes_lb->first; node; node = node->next) {
                bNode *new_node = node->new_node;
-               if (new_node->parent)
+               if (new_node->parent) {
                        new_node->parent = new_node->parent->new_node;
+               }
        }
 
        for (link = clipboard_links_lb->first; link; link = link->next) {
@@ -2105,9 +2194,11 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot)
 static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb)
 {
        bNodeSocket *sock;
-       for (sock = lb->first; sock; sock = sock->next)
-               if (sock->flag & SELECT)
+       for (sock = lb->first; sock; sock = sock->next) {
+               if (sock->flag & SELECT) {
                        return sock;
+               }
+       }
        return NULL;
 }
 
@@ -2143,10 +2234,12 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
        }
 
        /* deactivate sockets (has to check both lists) */
-       for (tsock = ntree->inputs.first; tsock; tsock = tsock->next)
+       for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) {
                tsock->flag &= ~SELECT;
-       for (tsock = ntree->outputs.first; tsock; tsock = tsock->next)
+       }
+       for (tsock = ntree->outputs.first; tsock; tsock = tsock->next) {
                tsock->flag &= ~SELECT;
+       }
        /* make the new socket active */
        sock->flag |= SELECT;
 
@@ -2183,18 +2276,21 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op))
        bNodeSocket *iosock, *active_sock;
 
        iosock = ntree_get_active_interface_socket(&ntree->inputs);
-       if (!iosock)
+       if (!iosock) {
                iosock = ntree_get_active_interface_socket(&ntree->outputs);
-       if (!iosock)
+       }
+       if (!iosock) {
                return OPERATOR_CANCELLED;
+       }
 
        /* preferably next socket becomes active, otherwise try previous socket */
        active_sock = (iosock->next ? iosock->next : iosock->prev);
        ntreeRemoveSocketInterface(ntree, iosock);
 
        /* set active socket */
-       if (active_sock)
+       if (active_sock) {
                active_sock->flag |= SELECT;
+       }
 
        ntreeUpdateTree(CTX_data_main(C), ntree);
 
@@ -2240,28 +2336,33 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
                lb = &ntree->outputs;
                iosock = ntree_get_active_interface_socket(lb);
        }
-       if (!iosock)
+       if (!iosock) {
                return OPERATOR_CANCELLED;
+       }
 
        switch (direction) {
                case 1:
                {       /* up */
                        bNodeSocket *before = iosock->prev;
                        BLI_remlink(lb, iosock);
-                       if (before)
+                       if (before) {
                                BLI_insertlinkbefore(lb, before, iosock);
-                       else
+                       }
+                       else {
                                BLI_addhead(lb, iosock);
+                       }
                        break;
                }
                case 2:
                {       /* down */
                        bNodeSocket *after = iosock->next;
                        BLI_remlink(lb, iosock);
-                       if (after)
+                       if (after) {
                                BLI_insertlinkafter(lb, after, iosock);
-                       else
+                       }
+                       else {
                                BLI_addtail(lb, iosock);
+                       }
                        break;
                }
        }
@@ -2301,14 +2402,16 @@ static bool node_shader_script_update_poll(bContext *C)
        Text *text;
 
        /* test if we have a render engine that supports shaders scripts */
-       if (!(type && type->update_script_node))
+       if (!(type && type->update_script_node)) {
                return 0;
+       }
 
        /* see if we have a shader script node in context */
        node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
 
-       if (!node && snode && snode->edittree)
+       if (!node && snode && snode->edittree) {
                node = nodeGetActive(snode->edittree);
+       }
 
        if (node && node->type == SH_NODE_SCRIPT) {
                NodeShaderScript *nss = node->storage;
@@ -2320,8 +2423,9 @@ static bool node_shader_script_update_poll(bContext *C)
 
        /* see if we have a text datablock in context */
        text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
-       if (text)
+       if (text) {
                return 1;
+       }
 
        /* we don't check if text datablock is actually in use, too slow for poll */
 
@@ -2340,8 +2444,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende
        for (node = ntree->nodes.first; node; node = node->next) {
                if (node->type == NODE_GROUP) {
                        bNodeTree *ngroup = (bNodeTree *)node->id;
-                       if (ngroup && !ngroup->done)
+                       if (ngroup && !ngroup->done) {
                                found |= node_shader_script_update_text_recursive(engine, type, ngroup, text);
+                       }
                }
                else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) {
                        type->update_script_node(engine, ntree, node);
@@ -2392,19 +2497,22 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
                if (text) {
                        /* clear flags for recursion check */
                        FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
-                               if (ntree->type == NTREE_SHADER)
+                               if (ntree->type == NTREE_SHADER) {
                                        ntree->done = false;
+                               }
                        } FOREACH_NODETREE_END;
 
                        FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
                                if (ntree->type == NTREE_SHADER) {
-                                       if (!ntree->done)
+                                       if (!ntree->done) {
                                                found |= node_shader_script_update_text_recursive(engine, type, ntree, text);
+                                       }
                                }
                        } FOREACH_NODETREE_END;
 
-                       if (!found)
+                       if (!found) {
                                BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
+                       }
                }
        }
 
index 808d937..3de389d 100644 (file)
@@ -106,12 +106,15 @@ static const char *group_node_idname(bContext *C)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
 
-       if (ED_node_is_shader(snode))
+       if (ED_node_is_shader(snode)) {
                return "ShaderNodeGroup";
-       else if (ED_node_is_compositor(snode))
+       }
+       else if (ED_node_is_compositor(snode)) {
                return "CompositorNodeGroup";
-       else if (ED_node_is_texture(snode))
+       }
+       else if (ED_node_is_texture(snode)) {
                return "TextureNodeGroup";
+       }
 
        return "";
 }
@@ -121,10 +124,12 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
        SpaceNode *snode = CTX_wm_space_node(C);
        bNode *node = nodeGetActive(snode->edittree);
 
-       if (node && STREQ(node->idname, node_idname))
+       if (node && STREQ(node->idname, node_idname)) {
                return node;
-       else
+       }
+       else {
                return NULL;
+       }
 }
 
 /* ***************** Edit Group operator ************* */
@@ -143,11 +148,13 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
        if (gnode && !exit) {
                bNodeTree *ngroup = (bNodeTree *)gnode->id;
 
-               if (ngroup)
+               if (ngroup) {
                        ED_node_tree_push(snode, ngroup, gnode);
+               }
        }
-       else
+       else {
                ED_node_tree_pop(snode);
+       }
 
        WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
 
@@ -185,8 +192,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
        ngroup = (bNodeTree *)gnode->id;
 
        /* clear new pointers, set in copytree */
-       for (node = ntree->nodes.first; node; node = node->next)
+       for (node = ntree->nodes.first; node; node = node->next) {
                node->new_node = NULL;
+       }
 
        /* wgroup is a temporary copy of the NodeTree we're merging in
         * - all of wgroup's nodes are transferred across to their new home
@@ -217,8 +225,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
                        RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
                        path = RNA_path_from_ID_to_struct(&ptr);
 
-                       if (path)
+                       if (path) {
                                BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+                       }
                }
 
                /* migrate node */
@@ -359,8 +368,9 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
        ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
 
        gnode = node_group_get_active(C, node_idname);
-       if (!gnode)
+       if (!gnode) {
                return OPERATOR_CANCELLED;
+       }
 
        if (gnode->id && node_group_ungroup(bmain, snode->edittree, gnode)) {
                ntreeUpdateTree(bmain, snode->nodetree);
@@ -402,18 +412,21 @@ static int node_group_separate_selected(
        ListBase anim_basepaths = {NULL, NULL};
 
        /* deselect all nodes in the target tree */
-       for (node = ntree->nodes.first; node; node = node->next)
+       for (node = ntree->nodes.first; node; node = node->next) {
                nodeSetSelected(node, false);
+       }
 
        /* clear new pointers, set in BKE_node_copy_ex(). */
-       for (node = ngroup->nodes.first; node; node = node->next)
+       for (node = ngroup->nodes.first; node; node = node->next) {
                node->new_node = NULL;
+       }
 
        /* add selected nodes into the ntree */
        for (node = ngroup->nodes.first; node; node = node_next) {
                node_next = node->next;
-               if (!(node->flag & NODE_SELECT))
+               if (!(node->flag & NODE_SELECT)) {
                        continue;
+               }
 
                /* ignore interface nodes */
                if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
@@ -440,13 +453,15 @@ static int node_group_separate_selected(
                        RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
                        path = RNA_path_from_ID_to_struct(&ptr);
 
-                       if (path)
+                       if (path) {
                                BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+                       }
                }
 
                /* ensure valid parent pointers, detach if parent stays inside the group */
-               if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
+               if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) {
                        nodeDetachNode(newnode);
+               }
 
                /* migrate node */
                BLI_remlink(&ngroup->nodes, newnode);
@@ -469,8 +484,9 @@ static int node_group_separate_selected(
 
                if (make_copy) {
                        /* make a copy of internal links */
-                       if (fromselect && toselect)
+                       if (fromselect && toselect) {
                                nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock);
+                       }
                }
                else {
                        /* move valid links over, delete broken links */
@@ -502,8 +518,9 @@ static int node_group_separate_selected(
        }
 
        ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
-       if (!make_copy)
+       if (!make_copy) {
                ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+       }
 
        return 1;
 }
@@ -633,16 +650,19 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const
        /* free local pseudo node tree again */
        ntreeFreeTree(ngroup);
        MEM_freeN(ngroup);
-       if (!ok)
+       if (!ok) {
                return false;
+       }
 
        /* check if all connections are OK, no unselected node has both
         * inputs and outputs to a selection */
        for (link = ntree->links.first; link; link = link->next) {
-               if (node_group_make_use_node(link->fromnode, gnode))
+               if (node_group_make_use_node(link->fromnode, gnode)) {
                        link->tonode->done |= 1;
-               if (node_group_make_use_node(link->tonode, gnode))
+               }
+               if (node_group_make_use_node(link->tonode, gnode)) {
                        link->fromnode->done |= 2;
+               }
        }
        for (node = ntree->nodes.first; node; node = node->next) {
                if (!(node->flag & NODE_SELECT) &&
@@ -696,16 +716,18 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
        static const float offsety = 0.0f;
 
        /* deselect all nodes in the target tree */
-       for (node = ngroup->nodes.first; node; node = node->next)
+       for (node = ngroup->nodes.first; node; node = node->next) {
                nodeSetSelected(node, false);
+       }
 
        totselect = node_get_selected_minmax(ntree, gnode, min, max);
        add_v2_v2v2(center, min, max);
        mul_v2_fl(center, 0.5f);
 
        /* auto-add interface for "solo" nodes */
-       if (totselect == 1)
+       if (totselect == 1) {
                expose_all = true;
+       }
 
        /* move nodes over */
        for (node = ntree->nodes.first; node; node = nextn) {
@@ -721,13 +743,15 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
                                RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
                                path = RNA_path_from_ID_to_struct(&ptr);
 
-                               if (path)
+                               if (path) {
                                        BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+                               }
                        }
 
                        /* ensure valid parent pointers, detach if parent stays outside the group */
-                       if (node->parent && !(node->parent->flag & NODE_SELECT))
+                       if (node->parent && !(node->parent->flag & NODE_SELECT)) {
                                nodeDetachNode(node);
+                       }
 
                        /* change node-collection membership */
                        BLI_remlink(&ntree->nodes, node);
@@ -857,8 +881,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
                                                        break;
                                                }
                                        }
-                                       if (skip)
+                                       if (skip) {
                                                continue;
+                                       }
 
                                        iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
 
@@ -872,11 +897,14 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
                                for (sock = node->outputs.first; sock; sock = sock->next) {
                                        bNodeSocket *iosock, *output_sock;
                                        bool skip = false;
-                                       for (link = ngroup->links.first; link; link = link->next)
-                                               if (link->fromsock == sock)
+                                       for (link = ngroup->links.first; link; link = link->next) {
+                                               if (link->fromsock == sock) {
                                                        skip = true;
-                                       if (skip)
+                                               }
+                                       }
+                                       if (skip) {
                                                continue;
+                                       }
 
                                        iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
 
@@ -906,8 +934,9 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree,
 
        totselect = node_get_selected_minmax(ntree, NULL, min, max);
        /* don't make empty group */
-       if (totselect == 0)
+       if (totselect == 0) {
                return NULL;
+       }
 
        /* new nodetree */
        ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype);
@@ -939,8 +968,9 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
 
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
-       if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports))
+       if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) {
                return OPERATOR_CANCELLED;
+       }
 
        gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname);
 
@@ -995,12 +1025,14 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
 
        gnode = node_group_get_active(C, node_idname);
 
-       if (!gnode || !gnode->id)
+       if (!gnode || !gnode->id) {
                return OPERATOR_CANCELLED;
+       }
 
        ngroup = (bNodeTree *)gnode->id;
-       if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports))
+       if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) {
                return OPERATOR_CANCELLED;
+       }
 
        node_group_make_insert_selected(C, ntree, gnode);
 
index 1aaf0ba..55a3da6 100644 (file)
@@ -200,19 +200,23 @@ static int sort_nodes_locx(const void *a, const void *b)
        const bNode *node1 = nli1->node;
        const bNode *node2 = nli2->node;
 
-       if (node1->locx > node2->locx)
+       if (node1->locx > node2->locx) {
                return 1;
-       else
+       }
+       else {
                return 0;
+       }
 }
 
 static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
 {
-       if (nodeSocketIsHidden(sock))
+       if (nodeSocketIsHidden(sock)) {
                return 0;
+       }
 
-       if (!allow_used && (sock->flag & SOCK_IN_USE))
+       if (!allow_used && (sock->flag & SOCK_IN_USE)) {
                return 0;
+       }
 
        return 1;
 }
@@ -223,30 +227,35 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke
 
        /* first look for selected output */
        for (sock = node->outputs.first; sock; sock = sock->next) {
-               if (!socket_is_available(ntree, sock, allow_multiple))
+               if (!socket_is_available(ntree, sock, allow_multiple)) {
                        continue;
+               }
 
-               if (sock->flag & SELECT)
+               if (sock->flag & SELECT) {
                        return sock;
+               }
        }
 
        /* try to find a socket with a matching name */
        for (sock = node->outputs.first; sock; sock = sock->next) {
-               if (!socket_is_available(ntree, sock, allow_multiple))
+               if (!socket_is_available(ntree, sock, allow_multiple)) {
                        continue;
+               }
 
                /* check for same types */
                if (sock->type == sock_target->type) {
-                       if (STREQ(sock->name, sock_target->name))
+                       if (STREQ(sock->name, sock_target->name)) {
                                return sock;
+                       }
                }
        }
 
        /* otherwise settle for the first available socket of the right type */
        for (sock = node->outputs.first; sock; sock = sock->next) {
 
-               if (!socket_is_available(ntree, sock, allow_multiple))
+               if (!socket_is_available(ntree, sock, allow_multiple)) {
                        continue;
+               }
 
                /* check for same types */
                if (sock->type == sock_target->type) {
@@ -282,8 +291,9 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
                                /* increment to make sure we don't keep finding
                                 * the same socket on every attempt running this function */
                                a++;
-                               if (a > num)
+                               if (a > num) {
                                        return sock;
+                               }
                        }
                }
        }
@@ -296,8 +306,9 @@ static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocke
        bNodeTree *ntree = snode->edittree;
 
        /* then we can connect */
-       if (replace)
+       if (replace) {
                nodeRemSocketLinks(ntree, sock_to);
+       }
 
        nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to);
        return true;
@@ -327,7 +338,9 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
                bNodeSocket *sock_fr, *sock_to;
                bool has_selected_inputs = false;
 
-               if (nli->next == NULL) break;
+               if (nli->next == NULL) {
+                       break;
+               }
 
                node_fr = nli->node;
                node_to = nli->next->node;
@@ -341,13 +354,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
                        if (sock_to->flag & SELECT) {
                                has_selected_inputs = 1;
 
-                               if (!socket_is_available(ntree, sock_to, replace))
+                               if (!socket_is_available(ntree, sock_to, replace)) {
                                        continue;
+                               }
 
                                /* check for an appropriate output socket to connect from */
                                sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
-                               if (!sock_fr)
+                               if (!sock_fr) {
                                        continue;
+                               }
 
                                if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
                                        numlinks++;
@@ -363,13 +378,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
 
                                /* find the best guess input socket */
                                sock_to = best_socket_input(ntree, node_to, i, replace);
-                               if (!sock_to)
+                               if (!sock_to) {
                                        continue;
+                               }
 
                                /* check for an appropriate output socket to connect from */
                                sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
-                               if (!sock_fr)
+                               if (!sock_fr) {
                                        continue;
+                               }
 
                                if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
                                        numlinks++;
@@ -397,16 +414,21 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
        bNodeSocket *sock;
 
        /* context check */
-       if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs))
+       if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) {
                return OPERATOR_CANCELLED;
-       if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
+       }
+       if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
                return OPERATOR_CANCELLED;
+       }
 
        /* get viewer */
-       for (node = snode->edittree->nodes.first; node; node = node->next)
-               if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
-                       if (node->flag & NODE_DO_OUTPUT)
+       for (node = snode->edittree->nodes.first; node; node = node->next) {
+               if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+                       if (node->flag & NODE_DO_OUTPUT) {
                                break;
+                       }
+               }
+       }
        /* no viewer, we make one active */
        if (node == NULL) {
                for (node = snode->edittree->nodes.first; node; node = node->next) {
@@ -422,19 +444,24 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
        /* try to find an already connected socket to cycle to the next */
        if (node) {
                link = NULL;
-               for (link = snode->edittree->links.first; link; link = link->next)
-                       if (link->tonode == node && link->fromnode == tonode)
-                               if (link->tosock == node->inputs.first)
+               for (link = snode->edittree->links.first; link; link = link->next) {
+                       if (link->tonode == node && link->fromnode == tonode) {
+                               if (link->tosock == node->inputs.first) {
                                        break;
+                               }
+                       }
+               }
                if (link) {
                        /* unlink existing connection */
                        sock = link->fromsock;
                        nodeRemLink(snode->edittree, link);
 
                        /* find a socket after the previously connected socket */
-                       for (sock = sock->next; sock; sock = sock->next)
-                               if (!nodeSocketIsHidden(sock))
+                       for (sock = sock->next; sock; sock = sock->next) {
+                               if (!nodeSocketIsHidden(sock)) {
                                        break;
+                               }
+                       }
                }
        }
 
@@ -451,9 +478,11 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
 
        /* find a socket starting from the first socket */
        if (!sock) {
-               for (sock = tonode->outputs.first; sock; sock = sock->next)
-                       if (!nodeSocketIsHidden(sock))
+               for (sock = tonode->outputs.first; sock; sock = sock->next) {
+                       if (!nodeSocketIsHidden(sock)) {
                                break;
+                       }
+               }
        }
 
        if (sock) {
@@ -461,16 +490,19 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
                if (!node) {
                        /* XXX location is a quick hack, just place it next to the linked socket */
                        node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
-                       if (!node)
+                       if (!node) {
                                return OPERATOR_CANCELLED;
+                       }
 
                        link = NULL;
                }
                else {
                        /* get link to viewer */
-                       for (link = snode->edittree->links.first; link; link = link->next)
-                               if (link->tonode == node && link->tosock == node->inputs.first)
+                       for (link = snode->edittree->links.first; link; link = link->next) {
+                               if (link->tonode == node && link->tosock == node->inputs.first) {
                                        break;
+                               }
+                       }
                }
 
                if (link == NULL) {
@@ -497,13 +529,15 @@ static int node_active_link_viewer_exec(bContext *C, wmOperator *UNUSED(op))
 
        node = nodeGetActive(snode->edittree);
 
-       if (!node)
+       if (!node) {
                return OPERATOR_CANCELLED;
+       }
 
        ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
-       if (node_link_viewer(C, node) == OPERATOR_CANCELLED)
+       if (node_link_viewer(C, node) == OPERATOR_CANCELLED) {
                return OPERATOR_CANCELLED;
+       }
 
        snode_notify(C, snode);
 
@@ -542,10 +576,12 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
        bNodeLink *link;
        int count = 0;
        for (link = ntree->links.first; link; link = link->next) {
-               if (link->fromsock == sock)
+               if (link->fromsock == sock) {
                        ++count;
-               if (link->tosock == sock)
+               }
+               if (link->tosock == sock) {
                        ++count;
+               }
        }
        return count;
 }
@@ -560,8 +596,9 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
 
        for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
                tlink_next = tlink->next;
-               if (tlink == link)
+               if (tlink == link) {
                        continue;
+               }
 
                if (tlink && tlink->fromsock == from) {
                        if (from_count > from->limit) {
@@ -605,10 +642,12 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
                        /* before actually adding the link,
                         * let nodes perform special link insertion handling
                         */
-                       if (link->fromnode->typeinfo->insert_link)
+                       if (link->fromnode->typeinfo->insert_link) {
                                link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link);
-                       if (link->tonode->typeinfo->insert_link)
+                       }
+                       if (link->tonode->typeinfo->insert_link) {
                                link->tonode->typeinfo->insert_link(ntree, link->tonode, link);
+                       }
 
                        /* add link to the node tree */
                        BLI_addtail(&ntree->links, link);
@@ -657,11 +696,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
                                bNodeLink *link = linkdata->data;
 
                                /* skip if this is already the target socket */
-                               if (link->tosock == tsock)
+                               if (link->tosock == tsock) {
                                        continue;
+                               }
                                /* skip if socket is on the same node as the fromsock */
-                               if (tnode && link->fromnode == tnode)
+                               if (tnode && link->fromnode == tnode) {
                                        continue;
+                               }
 
                                /* attach links to the socket */
                                link->tonode = tnode;
@@ -683,11 +724,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
                                bNodeLink *link = linkdata->data;
 
                                /* skip if this is already the target socket */
-                               if (link->fromsock == tsock)
+                               if (link->fromsock == tsock) {
                                        continue;
+                               }
                                /* skip if socket is on the same node as the fromsock */
-                               if (tnode && link->tonode == tnode)
+                               if (tnode && link->tonode == tnode) {
                                        continue;
+                               }
 
                                /* attach links to the socket */
                                link->fromnode = tnode;
@@ -829,8 +872,9 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
                                        nodeRemLink(snode->edittree, link);
 
                                        /* send changed event to original link->tonode */
-                                       if (node)
+                                       if (node) {
                                                snode_update(snode, node);
+                                       }
                                }
                        }
                }
@@ -881,8 +925,9 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
                return OPERATOR_RUNNING_MODAL;
        }
-       else
+       else {
                return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+       }
 }
 
 static void node_link_cancel(bContext *C, wmOperator *op)
@@ -965,10 +1010,13 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
 
        if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
 
-               for (i = 0; i < tot - 1; i++)
-                       for (b = 0; b < NODE_LINK_RESOL; b++)
-                               if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
+               for (i = 0; i < tot - 1; i++) {
+                       for (b = 0; b < NODE_LINK_RESOL; b++) {
+                               if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
                                        return 1;
+                               }
+                       }
+               }
        }
        return 0;
 }
@@ -990,7 +1038,9 @@ static int cut_links_exec(bContext *C, wmOperator *op)
                UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1],
                                         &mcoords[i][0], &mcoords[i][1]);
                i++;
-               if (i >= 256) break;
+               if (i >= 256) {
+                       break;
+               }
        }
        RNA_END;
 
@@ -1002,8 +1052,9 @@ static int cut_links_exec(bContext *C, wmOperator *op)
 
                for (link = snode->edittree->links.first; link; link = next) {
                        next = link->next;
-                       if (nodeLinkIsHidden(link))
+                       if (nodeLinkIsHidden(link)) {
                                continue;
+                       }
 
                        if (cut_links_intersect(link, mcoords, i)) {
 
@@ -1108,12 +1159,14 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceNode *snode = CTX_wm_space_node(C);
        bNodeTree *ntree = snode->edittree;
        bNode *frame = nodeGetActive(ntree), *node;
-       if (!frame || frame->type != NODE_FRAME)
+       if (!frame || frame->type != NODE_FRAME) {
                return OPERATOR_CANCELLED;
+       }
 
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (node == frame)
+               if (node == frame) {
                        continue;
+               }
                if (node->flag & NODE_SELECT) {
                        nodeDetachNode(node);
                        nodeAttachNode(node, frame);
@@ -1156,12 +1209,14 @@ static void node_join_attach_recursive(bNode *node, bNode *frame)
        }
        else if (node->parent) {
                /* call recursively */
-               if (!(node->parent->done & NODE_JOIN_DONE))
+               if (!(node->parent->done & NODE_JOIN_DONE)) {
                        node_join_attach_recursive(node->parent, frame);
+               }
 
                /* in any case: if the parent is a descendant, so is the child */
-               if (node->parent->done & NODE_JOIN_IS_DESCENDANT)
+               if (node->parent->done & NODE_JOIN_IS_DESCENDANT) {
                        node->done |= NODE_JOIN_IS_DESCENDANT;
+               }
                else if (node->flag & NODE_TEST) {
                        /* if parent is not an descendant of the frame, reattach the node */
                        nodeDetachNode(node);
@@ -1184,27 +1239,32 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
        /* XXX save selection: node_add_node call below sets the new frame as single
         * active+selected node */
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (node->flag & NODE_SELECT)
+               if (node->flag & NODE_SELECT) {
                        node->flag |= NODE_TEST;
-               else
+               }
+               else {
                        node->flag &= ~NODE_TEST;
+               }
        }
 
        frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
 
        /* reset tags */
-       for (node = ntree->nodes.first; node; node = node->next)
+       for (node = ntree->nodes.first; node; node = node->next) {
                node->done = 0;
+       }
 
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (!(node->done & NODE_JOIN_DONE))
+               if (!(node->done & NODE_JOIN_DONE)) {
                        node_join_attach_recursive(node, frame);
+               }
        }
 
        /* restore selection */
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (node->flag & NODE_TEST)
+               if (node->flag & NODE_TEST) {
                        node->flag |= NODE_SELECT;
+               }
        }
 
        ED_node_sort(ntree);
@@ -1241,10 +1301,12 @@ static bNode *node_find_frame_to_attach(ARegion *ar, const bNodeTree *ntree, con
        /* check nodes front to back */
        for (frame = ntree->nodes.last; frame; frame = frame->prev) {
                /* skip selected, those are the nodes we want to attach */
-               if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT))
+               if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
                        continue;
-               if (BLI_rctf_isect_pt_v(&frame->totr, cursor))
+               }
+               if (BLI_rctf_isect_pt_v(&frame->totr, cursor)) {
                        return frame;
+               }
        }
 
        return NULL;
@@ -1323,12 +1385,14 @@ static void node_detach_recursive(bNode *node)
 
        if (node->parent) {
                /* call recursively */
-               if (!(node->parent->done & NODE_DETACH_DONE))
+               if (!(node->parent->done & NODE_DETACH_DONE)) {
                        node_detach_recursive(node->parent);
+               }
 
                /* in any case: if the parent is a descendant, so is the child */
-               if (node->parent->done & NODE_DETACH_IS_DESCENDANT)
+               if (node->parent->done & NODE_DETACH_IS_DESCENDANT) {
                        node->done |= NODE_DETACH_IS_DESCENDANT;
+               }
                else if (node->flag & NODE_SELECT) {
                        /* if parent is not a descendant of a selected node, detach */
                        nodeDetachNode(node);
@@ -1349,14 +1413,16 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op))
        bNode *node;
 
        /* reset tags */
-       for (node = ntree->nodes.first; node; node = node->next)
+       for (node = ntree->nodes.first; node; node = node->next) {
                node->done = 0;
+       }
        /* detach nodes recursively
         * relative order is preserved here!
         */
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (!(node->done & NODE_DETACH_DONE))
+               if (!(node->done & NODE_DETACH_DONE)) {
                        node_detach_recursive(node);
+               }
        }
 
        ED_node_sort(ntree);
@@ -1394,8 +1460,9 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
        *r_select = NULL;
 
        /* no unlucky accidents */
-       if (sa == NULL || sa->spacetype != SPACE_NODE)
+       if (sa == NULL || sa->spacetype != SPACE_NODE) {
                return false;
+       }
 
        if (!test) {
                /* no need to look for a node */
@@ -1404,27 +1471,33 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
 
        for (node = snode->edittree->nodes.first; node; node = node->next) {
                if (node->flag & SELECT) {
-                       if (select)
+                       if (select) {
                                break;
-                       else
+                       }
+                       else {
                                select = node;
+                       }
                }
        }
        /* only one selected */
-       if (node || select == NULL)
+       if (node || select == NULL) {
                return false;
+       }
 
        /* correct node */
-       if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs))
+       if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) {
                return false;
+       }
 
        /* test node for links */
        for (link = snode->edittree->links.first; link; link = link->next) {
-               if (nodeLinkIsHidden(link))
+               if (nodeLinkIsHidden(link)) {
                        continue;
+               }
 
-               if (link->tonode == select || link->fromnode == select)
+               if (link->tonode == select || link->fromnode == select) {
                        return false;
+               }
        }
 
        *r_select = select;
@@ -1439,20 +1512,26 @@ void ED_node_link_intersect_test(ScrArea *sa, int test)
        bNodeLink *link, *selink = NULL;
        float dist_best = FLT_MAX;
 
-       if (!ed_node_link_conditions(sa, test, &snode, &select)) return;
+       if (!ed_node_link_conditions(sa, test, &snode, &select)) {
+               return;
+       }
 
        /* clear flags */
-       for (link = snode->edittree->links.first; link; link = link->next)
+       for (link = snode->edittree->links.first; link; link = link->next) {
                link->flag &= ~NODE_LINKFLAG_HILITE;
+       }
 
-       if (test == 0) return;
+       if (test == 0) {
+               return;
+       }
 
        /* find link to select/highlight */
        for (link = snode->edittree->links.first; link; link = link->next) {
                float coord_array[NODE_LINK_RESOL + 1][2];
 
-               if (nodeLinkIsHidden(link))
+               if (nodeLinkIsHidden(link)) {
                        continue;
+               }
 
                if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
                        float dist = FLT_MAX;
@@ -1482,8 +1561,9 @@ void ED_node_link_intersect_test(ScrArea *sa, int test)
                }
        }
 
-       if (selink)
+       if (selink) {
                selink->flag |= NODE_LINKFLAG_HILITE;
+       }
 }
 
 /* assumes sockets in list */
@@ -1493,8 +1573,9 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
        int type, maxtype = 0;
 
        /* find type range */
-       for (sock = sockets->first; sock; sock = sock->next)
+       for (sock = sockets->first; sock; sock = sock->next) {
                maxtype = max_ii(sock->type, maxtype);
+       }
 
        /* try all types, starting from 'highest' (i.e. colors, vectors, values) */
        for (type = maxtype; type >= 0; --type) {
@@ -1670,8 +1751,9 @@ static void node_link_insert_offset_ntree(
                /* check nodes front to back */
                for (frame = ntree->nodes.last; frame; frame = frame->prev) {
                        /* skip selected, those are the nodes we want to attach */
-                       if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT))
+                       if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
                                continue;
+                       }
 
                        /* for some reason frame y coords aren't correct yet */
                        node_to_updated_rect(frame, &totr_frame);
@@ -1757,8 +1839,9 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
        float duration;
        bool redraw = false;
 
-       if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata)
+       if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) {
                return OPERATOR_PASS_THROUGH;
+       }
 
        duration = (float)iofsd->anim_timer->duration;
 
@@ -1808,8 +1891,9 @@ static int node_insert_offset_invoke(bContext *C, wmOperator *op, const wmEvent
        const SpaceNode *snode = CTX_wm_space_node(C);
        NodeInsertOfsData *iofsd = snode->iofsd;
 
-       if (!iofsd || !iofsd->insert)
+       if (!iofsd || !iofsd->insert) {
                return OPERATOR_CANCELLED;
+       }
 
        BLI_assert((snode->flag & SNODE_SKIP_INSOFFSET) == 0);
 
@@ -1850,12 +1934,16 @@ void ED_node_link_insert(Main *bmain, ScrArea *sa)
        bNodeLink *link;
        bNodeSocket *sockto;
 
-       if (!ed_node_link_conditions(sa, true, &snode, &select)) return;
+       if (!ed_node_link_conditions(sa, t