[Bf-blender-cvs] [34ff27025d4] blender-v3.3-release: Cleanup: Remove one level of indentation by early continue in a loop.

Bastien Montagne noreply at git.blender.org
Tue Aug 30 15:18:22 CEST 2022


Commit: 34ff27025d442f6b5e65075e8c8b6aaad8e400b4
Author: Bastien Montagne
Date:   Tue Aug 30 14:35:17 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB34ff27025d442f6b5e65075e8c8b6aaad8e400b4

Cleanup: Remove one level of indentation by early continue in a loop.

===================================================================

M	source/blender/blenkernel/intern/lib_override.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index 0e09c36fd64..94642ad2116 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -1815,68 +1815,70 @@ static bool lib_override_library_resync(Main *bmain,
         id->tag |= LIB_TAG_MISSING;
       }
 
-      if ((id->lib == id_root->lib) && ID_IS_OVERRIDE_LIBRARY(id)) {
-        /* While this should not happen in typical cases (and won't be properly supported here),
-         * user is free to do all kind of very bad things, including having different local
-         * overrides of a same linked ID in a same hierarchy. */
-        IDOverrideLibrary *id_override_library = BKE_lib_override_library_get(
-            bmain, id, nullptr, nullptr);
-
-        if (id_override_library->hierarchy_root != id_root->override_library->hierarchy_root) {
-          continue;
-        }
+      if ((id->lib != id_root->lib) || !ID_IS_OVERRIDE_LIBRARY(id)) {
+        continue;
+      }
 
-        ID *reference_id = id_override_library->reference;
-        if (GS(reference_id->name) != GS(id->name)) {
-          switch (GS(id->name)) {
-            case ID_KE:
-              reference_id = reinterpret_cast<ID *>(BKE_key_from_id(reference_id));
-              break;
-            case ID_GR:
-              BLI_assert(GS(reference_id->name) == ID_SCE);
-              reference_id = reinterpret_cast<ID *>(
-                  reinterpret_cast<Scene *>(reference_id)->master_collection);
-              break;
-            case ID_NT:
-              reference_id = reinterpret_cast<ID *>(ntreeFromID(id));
-              break;
-            default:
-              break;
-          }
+      /* While this should not happen in typical cases (and won't be properly supported here),
+       * user is free to do all kind of very bad things, including having different local
+       * overrides of a same linked ID in a same hierarchy. */
+      IDOverrideLibrary *id_override_library = BKE_lib_override_library_get(
+          bmain, id, nullptr, nullptr);
+
+      if (id_override_library->hierarchy_root != id_root->override_library->hierarchy_root) {
+        continue;
+      }
+
+      ID *reference_id = id_override_library->reference;
+      if (GS(reference_id->name) != GS(id->name)) {
+        switch (GS(id->name)) {
+          case ID_KE:
+            reference_id = reinterpret_cast<ID *>(BKE_key_from_id(reference_id));
+            break;
+          case ID_GR:
+            BLI_assert(GS(reference_id->name) == ID_SCE);
+            reference_id = reinterpret_cast<ID *>(
+                reinterpret_cast<Scene *>(reference_id)->master_collection);
+            break;
+          case ID_NT:
+            reference_id = reinterpret_cast<ID *>(ntreeFromID(id));
+            break;
+          default:
+            break;
         }
-        if (reference_id == nullptr) {
-          /* Can happen e.g. when there is a local override of a shapekey, but the matching linked
-           * obdata (mesh etc.) does not have any shapekey anymore. */
+      }
+      if (reference_id == nullptr) {
+        /* Can happen e.g. when there is a local override of a shapekey, but the matching linked
+         * obdata (mesh etc.) does not have any shapekey anymore. */
+        continue;
+      }
+      BLI_assert(GS(reference_id->name) == GS(id->name));
+
+      if (!BLI_ghash_haskey(linkedref_to_old_override, reference_id)) {
+        BLI_ghash_insert(linkedref_to_old_override, reference_id, id);
+        if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || (id->tag & LIB_TAG_DOIT) == 0) {
           continue;
         }
-        BLI_assert(GS(reference_id->name) == GS(id->name));
+        if ((id->override_library->reference->tag & LIB_TAG_DOIT) == 0) {
+          /* We have an override, but now it does not seem to be necessary to override that ID
+           * anymore. Check if there are some actual overrides from the user, otherwise assume
+           * that we can get rid of this local override. */
+          LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
+            if (!ELEM(op->rna_prop_type, PROP_POINTER, PROP_COLLECTION)) {
+              id->override_library->reference->tag |= LIB_TAG_DOIT;
+              break;
+            }
 
-        if (!BLI_ghash_haskey(linkedref_to_old_override, reference_id)) {
-          BLI_ghash_insert(linkedref_to_old_override, reference_id, id);
-          if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || (id->tag & LIB_TAG_DOIT) == 0) {
-            continue;
-          }
-          if ((id->override_library->reference->tag & LIB_TAG_DOIT) == 0) {
-            /* We have an override, but now it does not seem to be necessary to override that ID
-             * anymore. Check if there are some actual overrides from the user, otherwise assume
-             * that we can get rid of this local override. */
-            LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
-              if (!ELEM(op->rna_prop_type, PROP_POINTER, PROP_COLLECTION)) {
+            bool do_break = false;
+            LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
+              if ((opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) {
                 id->override_library->reference->tag |= LIB_TAG_DOIT;
+                do_break = true;
                 break;
               }
-
-              bool do_break = false;
-              LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
-                if ((opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) {
-                  id->override_library->reference->tag |= LIB_TAG_DOIT;
-                  do_break = true;
-                  break;
-                }
-              }
-              if (do_break) {
-                break;
-              }
+            }
+            if (do_break) {
+              break;
             }
           }
         }
@@ -1919,60 +1921,62 @@ static bool lib_override_library_resync(Main *bmain,
   ListBase *lb;
   FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
     FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) {
-      if (id->tag & LIB_TAG_DOIT && id->newid != nullptr && id->lib == id_root_reference->lib) {
-        ID *id_override_new = id->newid;
-        ID *id_override_old = static_cast<ID *>(BLI_ghash_lookup(linkedref_to_old_override, id));
+      if ((id->tag & LIB_TAG_DOIT) == 0 || id->newid == nullptr ||
+          id->lib != id_root_reference->lib) {
+        continue;
+      }
+      ID *id_override_new = id->newid;
+      ID *id_override_old = static_cast<ID *>(BLI_ghash_lookup(linkedref_to_old_override, id));
 
-        BLI_assert((id_override_new->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0);
-
-        /* We need to 'move back' newly created override into its proper library (since it was
-         * duplicated from the reference ID with 'no main' option, it should currently be the same
-         * as the reference ID one). */
-        BLI_assert(/*!ID_IS_LINKED(id_override_new) || */ id_override_new->lib == id->lib);
-        BLI_assert(id_override_old == nullptr || id_override_old->lib == id_root->lib);
-        id_override_new->lib = id_root->lib;
-        /* Remap step below will tag directly linked ones properly as needed. */
-        if (ID_IS_LINKED(id_override_new)) {
-          id_override_new->tag |= LIB_TAG_INDIRECT;
-        }
+      BLI_assert((id_override_new->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0);
+
+      /* We need to 'move back' newly created override into its proper library (since it was
+       * duplicated from the reference ID with 'no main' option, it should currently be the same
+       * as the reference ID one). */
+      BLI_assert(/*!ID_IS_LINKED(id_override_new) || */ id_override_new->lib == id->lib);
+      BLI_assert(id_override_old == nullptr || id_override_old->lib == id_root->lib);
+      id_override_new->lib = id_root->lib;
+      /* Remap step below will tag directly linked ones properly as needed. */
+      if (ID_IS_LINKED(id_override_new)) {
+        id_override_new->tag |= LIB_TAG_INDIRECT;
+      }
 
-        if (id_override_old != nullptr) {
-          /* Swap the names between old override ID and new one. */
-          char id_name_buf[MAX_ID_NAME];
-          memcpy(id_name_buf, id_override_old->name, sizeof(id_name_buf));
-          memcpy(id_override_old->name, id_override_new->name, sizeof(id_override_old->name));
-          memcpy(id_override_new->name, id_name_buf, sizeof(id_override_new->name));
-
-          BLI_insertlinkreplace(lb, id_override_old, id_override_new);
-          id_override_old->tag |= LIB_TAG_NO_MAIN;
-          id_override_new->tag &= ~LIB_TAG_NO_MAIN;
-
-          lib_override_object_posemode_transfer(id_override_new, id_override_old);
-
-          if (ID_IS_OVERRIDE_LIBRARY_REAL(id_override_new)) {
-            BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_override_old));
-
-            id_override_new->override_library->flag = id_override_old->override_library->flag;
-
-            /* Copy over overrides rules from old override ID to new one. */
-            BLI_duplicatelist(&id_override_new->override_library->properties,
-                              &id_override_old->override_library->properties);
-            IDOverrideLibraryProperty *op_new = static_cast<IDOverrideLibraryProperty *>(
-                id_override_new->override_library->properties.first);
-            IDOverrideLibraryProperty *op_old = static_cast<IDOverrideLibraryProperty *>(
-                id_override_old->override_library->properties.first);
-            for (; op_new; op_new = op_new->next, op_old = op_old->next) {
-              lib_override_library_property_copy(op_new, op_old);
-            }
+      if (id_override_old != nullptr) {
+        /* Swap the names between old override ID and new one. */
+        char id_name_buf[MAX_ID_NAME];
+        memcpy(id_name_buf, id_override_old->name, sizeof(id_name_buf));
+        memcpy(id_override_old->name, id_override_new->name, sizeof(id_override_old->name));
+        m

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list