:fix valgrind issues
This commit is contained in:
parent
f29f62c3f7
commit
53dcff8745
@ -150,6 +150,7 @@ static constexpr Protocol::DeviceStatusV1 defaultStatusV1 = {
|
|||||||
Device::Device(QString serial)
|
Device::Device(QString serial)
|
||||||
{
|
{
|
||||||
info = defaultInfo;
|
info = defaultInfo;
|
||||||
|
status = {};
|
||||||
|
|
||||||
m_handle = nullptr;
|
m_handle = nullptr;
|
||||||
infoValid = false;
|
infoValid = false;
|
||||||
|
@ -281,13 +281,13 @@ void AppWindow::closeEvent(QCloseEvent *event)
|
|||||||
for(auto m : Mode::getModes()) {
|
for(auto m : Mode::getModes()) {
|
||||||
m->shutdown();
|
m->shutdown();
|
||||||
}
|
}
|
||||||
delete device;
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("geometry", saveGeometry());
|
settings.setValue("geometry", saveGeometry());
|
||||||
// deactivate currently used mode (stores mode state in settings)
|
// deactivate currently used mode (stores mode state in settings)
|
||||||
if(Mode::getActiveMode()) {
|
if(Mode::getActiveMode()) {
|
||||||
Mode::getActiveMode()->deactivate();
|
Mode::getActiveMode()->deactivate();
|
||||||
}
|
}
|
||||||
|
delete device;
|
||||||
pref.store();
|
pref.store();
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,22 @@ void SCPI::input(QString line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCPINode::~SCPINode()
|
||||||
|
{
|
||||||
|
if(parent) {
|
||||||
|
parent->remove(this);
|
||||||
|
}
|
||||||
|
while(commands.size() > 0) {
|
||||||
|
delete commands.front();
|
||||||
|
commands.erase(commands.begin());
|
||||||
|
}
|
||||||
|
while(subnodes.size() > 0) {
|
||||||
|
auto node = subnodes.front();
|
||||||
|
remove(node);
|
||||||
|
delete node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SCPINode::add(SCPINode *node)
|
bool SCPINode::add(SCPINode *node)
|
||||||
{
|
{
|
||||||
if(nameCollision(node->name)) {
|
if(nameCollision(node->name)) {
|
||||||
@ -103,6 +119,7 @@ bool SCPINode::add(SCPINode *node)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
subnodes.push_back(node);
|
subnodes.push_back(node);
|
||||||
|
node->parent = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +128,7 @@ bool SCPINode::remove(SCPINode *node)
|
|||||||
auto it = std::find(subnodes.begin(), subnodes.end(), node);
|
auto it = std::find(subnodes.begin(), subnodes.end(), node);
|
||||||
if(it != subnodes.end()) {
|
if(it != subnodes.end()) {
|
||||||
subnodes.erase(it);
|
subnodes.erase(it);
|
||||||
|
node->parent = nullptr;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,8 +16,8 @@ public:
|
|||||||
QString execute(QStringList params);
|
QString execute(QStringList params);
|
||||||
QString query(QStringList params);
|
QString query(QStringList params);
|
||||||
QString name() {return _name;}
|
QString name() {return _name;}
|
||||||
bool queryable() { return fn_query != nullptr;};
|
bool queryable() { return fn_query != nullptr;}
|
||||||
bool executable() { return fn_cmd != nullptr;};
|
bool executable() { return fn_cmd != nullptr;}
|
||||||
private:
|
private:
|
||||||
const QString _name;
|
const QString _name;
|
||||||
std::function<QString(QStringList)> fn_cmd;
|
std::function<QString(QStringList)> fn_cmd;
|
||||||
@ -28,7 +28,8 @@ class SCPINode {
|
|||||||
friend class SCPI;
|
friend class SCPI;
|
||||||
public:
|
public:
|
||||||
SCPINode(QString name) :
|
SCPINode(QString name) :
|
||||||
name(name){}
|
name(name), parent(nullptr){}
|
||||||
|
~SCPINode();
|
||||||
|
|
||||||
bool add(SCPINode *node);
|
bool add(SCPINode *node);
|
||||||
bool remove(SCPINode *node);
|
bool remove(SCPINode *node);
|
||||||
@ -41,6 +42,7 @@ private:
|
|||||||
const QString name;
|
const QString name;
|
||||||
std::vector<SCPINode*> subnodes;
|
std::vector<SCPINode*> subnodes;
|
||||||
std::vector<SCPICommand*> commands;
|
std::vector<SCPICommand*> commands;
|
||||||
|
SCPINode *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SCPI : public QObject, public SCPINode
|
class SCPI : public QObject, public SCPINode
|
||||||
|
Loading…
Reference in New Issue
Block a user