diff options
author | Bastien Montagne <bastien@blender.org> | 2021-03-16 17:07:45 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-03-16 18:57:04 +0300 |
commit | 18371f278059c0a2c99b91d5be4886ab3fd4a2a7 (patch) | |
tree | 0d7e4a5579d3b06e3f5cf5cc4825532faf08462b /source/blender/editors/space_outliner/tree | |
parent | b71b1ae384a3e8cda43bb005a1beeddbf30f86ed (diff) |
LibOverride: tweak log messages, fix crash in log code.
One of the log call could use freed memory.
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_overrides.cc | 86 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_overrides.hh | 51 |
2 files changed, 137 insertions, 0 deletions
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 |