forked from bartvdbraak/blender
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
This commit is contained in:
parent
417224a31b
commit
88de58fd1a
@ -29,7 +29,6 @@ Checks: >
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-integer-division,
|
||||
|
||||
-bugprone-exception-escape,
|
||||
-bugprone-redundant-branch-condition,
|
||||
|
||||
modernize-*,
|
||||
|
@ -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<bool(ID_Type id_type)> &filter)
|
||||
template<typename FilterFunc>
|
||||
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;
|
||||
|
@ -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<bool(ID_Type id_type)> &filter);
|
||||
|
||||
/* Add new relationship between two nodes. */
|
||||
Relation *add_new_relation(Node *from, Node *to, const char *description, int flags = 0);
|
||||
|
@ -41,11 +41,6 @@ PSStrokeRenderer::PSStrokeRenderer(const char *iFileName)
|
||||
_ofstream << "%%EndComments" << endl;
|
||||
}
|
||||
|
||||
PSStrokeRenderer::~PSStrokeRenderer()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void PSStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
||||
{
|
||||
RenderStrokeRepBasic(iStrokeRep);
|
||||
@ -90,11 +85,4 @@ void PSStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
||||
}
|
||||
}
|
||||
|
||||
void PSStrokeRenderer::Close()
|
||||
{
|
||||
if (_ofstream.is_open()) {
|
||||
_ofstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace Freestyle */
|
||||
|
@ -40,15 +40,11 @@ namespace Freestyle {
|
||||
class PSStrokeRenderer : public StrokeRenderer {
|
||||
public:
|
||||
PSStrokeRenderer(const char *iFileName = NULL);
|
||||
virtual ~PSStrokeRenderer();
|
||||
|
||||
/*! Renders a stroke rep */
|
||||
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
|
||||
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
|
||||
|
||||
/*! Closes the output PS file */
|
||||
void Close();
|
||||
|
||||
protected:
|
||||
mutable ofstream _ofstream;
|
||||
};
|
||||
|
@ -38,11 +38,6 @@ TextStrokeRenderer::TextStrokeRenderer(const char *iFileName)
|
||||
_ofstream << "%u x y z tleft tright r g b ..." << endl;
|
||||
}
|
||||
|
||||
TextStrokeRenderer::~TextStrokeRenderer()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void TextStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
||||
{
|
||||
RenderStrokeRepBasic(iStrokeRep);
|
||||
@ -68,11 +63,4 @@ void TextStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
||||
_ofstream << endl;
|
||||
}
|
||||
|
||||
void TextStrokeRenderer::Close()
|
||||
{
|
||||
if (_ofstream.is_open()) {
|
||||
_ofstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace Freestyle */
|
||||
|
@ -53,15 +53,11 @@ namespace Freestyle {
|
||||
class TextStrokeRenderer : public StrokeRenderer {
|
||||
public:
|
||||
TextStrokeRenderer(const char *iFileName = NULL);
|
||||
virtual ~TextStrokeRenderer();
|
||||
|
||||
/*! Renders a stroke rep */
|
||||
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
|
||||
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
|
||||
|
||||
/*! Closes the output file */
|
||||
void Close();
|
||||
|
||||
protected:
|
||||
mutable ofstream _ofstream;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user