Примеры ошибок, обнаруженных с помощью диагностики V1002
V1002. Class that contains pointers, constructor and destructor is copied by the automatically generated operator= or copy constructor.
Ardour
V1002 The 'XMLProcessorSelection' class, containing pointers, constructor and destructor, is copied by the automatically generated operator=. processor_selection.cc 25
XMLProcessorSelection processors;
ProcessorSelection&
ProcessorSelection::operator= (ProcessorSelection const & other)
{
if (this != &other) {
processors = other.processors; // <=
}
return *this;
}
class XMLProcessorSelection {
public:
XMLProcessorSelection() : node (0) {}
~XMLProcessorSelection() { if (node) { delete node; } }
void set (XMLNode* n) {
if (node) {
delete node;
}
node = n;
}
void add (XMLNode* newchild) {
if (!node) {
node = new XMLNode ("add");
}
node->add_child_nocopy (*newchild);
}
void clear () {
if (node) {
delete node;
node = 0;
}
}
bool empty () const { return node == 0 || ....empty(); }
const XMLNode& get_node() const { return *node; }
private:
XMLNode* node; // <=
};
Instead of assignment, set() or add() functions had to be used.