[Bf-blender-cvs] [18371f27805] master: LibOverride: tweak log messages, fix crash in log code.

Bastien Montagne noreply at git.blender.org
Tue Mar 16 16:57:09 CET 2021


Commit: 18371f278059c0a2c99b91d5be4886ab3fd4a2a7
Author: Bastien Montagne
Date:   Tue Mar 16 15:07:45 2021 +0100
Branches: master
https://developer.blender.org/rB18371f278059c0a2c99b91d5be4886ab3fd4a2a7

LibOverride: tweak log messages, fix crash in log code.

One of the log call could use freed memory.

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

M	source/blender/blenkernel/intern/lib_override.c
A	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
A	source/blender/editors/space_outliner/tree/tree_element_overrides.hh
M	source/blender/makesrna/intern/rna_access_compare_override.c

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 6cdc7fce34b..3f47e11f701 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1024,13 +1024,13 @@ bool BKE_lib_override_library_resync(
         /* If user never edited them, we can delete them. */
         id->tag |= LIB_TAG_DOIT;
         id->tag &= ~LIB_TAG_MISSING;
-        CLOG_INFO(&LOG, 3, "Old override %s is being deleted", id->name);
+        CLOG_INFO(&LOG, 2, "Old override %s is being deleted", id->name);
       }
       else {
         /* Otherwise, keep them, user needs to decide whether what to do with them. */
         BLI_assert((id->tag & LIB_TAG_DOIT) == 0);
         id_fake_user_set(id);
-        CLOG_INFO(&LOG, 3, "Old override %s is being kept around as it was user-edited", id->name);
+        CLOG_INFO(&LOG, 2, "Old override %s is being kept around as it was user-edited", id->name);
       }
     }
   }
@@ -1158,8 +1158,9 @@ void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *
           continue;
         }
         do_continue = true;
+        CLOG_INFO(&LOG, 2, "Resyncing %s...", id->name);
         const bool success = BKE_lib_override_library_resync(bmain, scene, view_layer, id, false);
-        CLOG_INFO(&LOG, 2, "Resynced %s, success: %d", id->name, success);
+        CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
         break;
       }
       FOREACH_MAIN_LISTBASE_ID_END;
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
new file mode 100644
index 00000000000..4d9634541af
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
@@ -0,0 +1,86 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#include "BKE_collection.h"
+#include "BKE_lib_override.h"
+
+#include "BLI_utildefines.h"
+
+#include "BLI_listbase_wrapper.hh"
+
+#include "BLT_translation.h"
+
+#include "RNA_access.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.h"
+
+#include "tree_element_overrides.hh"
+
+namespace blender::ed::outliner {
+
+TreeElementOverridesBase::TreeElementOverridesBase(TreeElement &legacy_te, ID &id)
+    : AbstractTreeElement(legacy_te), id_(id)
+{
+  BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE_BASE);
+  legacy_te.name = IFACE_("Library Overrides");
+}
+
+void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const
+{
+  if (!id_.override_library) {
+    return;
+  }
+
+  PointerRNA idpoin;
+  RNA_id_pointer_create(&id_, &idpoin);
+
+  PointerRNA override_rna_ptr;
+  PropertyRNA *override_rna_prop;
+  short index = 0;
+
+  for (auto *override_prop :
+       ListBaseWrapper<IDOverrideLibraryProperty>(id_.override_library->properties)) {
+    if (!BKE_lib_override_rna_property_find(
+            &idpoin, override_prop, &override_rna_ptr, &override_rna_prop)) {
+      /* This is fine, override properties list is not always fully up-to-date with current
+       * RNA/IDProps etc., this gets cleaned up when re-generating the overrides rules,
+       * no error here. */
+      continue;
+    }
+
+    TreeElementOverridesData data = {id_, *override_prop};
+    outliner_add_element(
+        &space_outliner, &legacy_te_.subtree, &data, &legacy_te_, TSE_LIBRARY_OVERRIDE, index++);
+  }
+}
+
+TreeElementOverridesProperty::TreeElementOverridesProperty(TreeElement &legacy_te,
+                                                           TreeElementOverridesData &override_data)
+    : AbstractTreeElement(legacy_te),
+      id_(override_data.id),
+      override_prop_(override_data.override_property)
+{
+  BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE);
+
+  legacy_te.name = override_prop_.rna_path;
+}
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
new file mode 100644
index 00000000000..9e80f3d6b08
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#pragma once
+
+#include "tree_element.hh"
+
+namespace blender::ed::outliner {
+
+struct TreeElementOverridesData {
+  ID &id;
+  IDOverrideLibraryProperty &override_property;
+};
+
+class TreeElementOverridesBase final : public AbstractTreeElement {
+  ID &id_;
+
+ public:
+  TreeElementOverridesBase(TreeElement &legacy_te, ID &id);
+
+  void expand(SpaceOutliner &) const override;
+};
+
+class TreeElementOverridesProperty final : public AbstractTreeElement {
+  ID &id_;
+  IDOverrideLibraryProperty &override_prop_;
+
+ public:
+  TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data);
+
+  void expand(SpaceOutliner &) const override;
+};
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 28d4cc4d075..d286d101b81 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -1107,7 +1107,7 @@ static void rna_property_override_apply_ex(Main *bmain,
                                                ptr_item_storage,
                                                opop)) {
       CLOG_INFO(&LOG,
-                2,
+                4,
                 "Failed to apply '%s' override operation on %s\n",
                 op->rna_path,
                 ptr_src->owner_id->name);
@@ -1211,7 +1211,7 @@ void RNA_struct_override_apply(Main *bmain,
 
             if (id_dst != NULL) {
               CLOG_INFO(&LOG,
-                        3,
+                        4,
                         "%s: Ignoring local override on ID pointer property '%s', as requested by "
                         "RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag",
                         ptr_dst->owner_id->name,
@@ -1236,7 +1236,7 @@ void RNA_struct_override_apply(Main *bmain,
       }
       else {
         CLOG_INFO(&LOG,
-                  2,
+                  4,
                   "Failed to apply library override operation to '%s.%s' "
                   "(could not resolve some properties, local:  %d, override: %d)",
                   ((ID *)ptr_src->owner_id)->name,



More information about the Bf-blender-cvs mailing list