From 88de58fd1af9ffb1c6afcc53cf6279aadc51f58c Mon Sep 17 00:00:00 2001 From: Ankit Meel Date: Tue, 17 Nov 2020 17:10:03 +0530 Subject: Clang-tidy, fix bugprone-exception-escape. Remove redundant call to `ofstream::close()` from `~PSStrokeRenderer` and `~TextStrokeRenderer`. ofstream will be destructed automatically. - For `~Depsgraph`, `std::function`'s constructor can throw. - Passing throwing statements in the lambda will not be detected by clang-tidy. Fix these issues by using lambda as function argument. Reviewed By: sergey, sybren Differential Revision: https://developer.blender.org/D9497 --- source/blender/depsgraph/intern/depsgraph.cc | 9 +++++---- source/blender/depsgraph/intern/depsgraph.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 870a6d3fce8..17eeba55a27 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -133,9 +133,10 @@ IDNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint) return id_node; } -void Depsgraph::clear_id_nodes_conditional(const std::function &filter) +template +static void clear_id_nodes_conditional(Depsgraph::IDDepsNodes *id_nodes, const FilterFunc &filter) { - for (IDNode *id_node : id_nodes) { + for (IDNode *id_node : *id_nodes) { if (id_node->id_cow == nullptr) { /* This means builder "stole" ownership of the copy-on-written * datablock for her own dirty needs. */ @@ -156,8 +157,8 @@ void Depsgraph::clear_id_nodes() /* Free memory used by ID nodes. */ /* Stupid workaround to ensure we free IDs in a proper order. */ - clear_id_nodes_conditional([](ID_Type id_type) { return id_type == ID_SCE; }); - clear_id_nodes_conditional([](ID_Type id_type) { return id_type != ID_PA; }); + clear_id_nodes_conditional(&id_nodes, [](ID_Type id_type) { return id_type == ID_SCE; }); + clear_id_nodes_conditional(&id_nodes, [](ID_Type id_type) { return id_type != ID_PA; }); for (IDNode *id_node : id_nodes) { delete id_node; diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index e03846f81e2..14c91834739 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -73,7 +73,6 @@ struct Depsgraph { IDNode *find_id_node(const ID *id) const; IDNode *add_id_node(ID *id, ID *id_cow_hint = nullptr); void clear_id_nodes(); - void clear_id_nodes_conditional(const std::function &filter); /* Add new relationship between two nodes. */ Relation *add_new_relation(Node *from, Node *to, const char *description, int flags = 0); -- cgit v1.2.3