aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-04-08 21:34:02 +0200
committerRenaud G <renaud@rolisteam.org>2015-04-08 21:34:02 +0200
commit5cfe48265ebad0ffa0a980dbc2d131fceeecdf3b (patch)
tree0d8d654046e18ad90a7a06e00e0e56c375a230fd /node
parent9192ba51a362715061cce1104b5543f7e93bf70f (diff)
downloadOneRoll-5cfe48265ebad0ffa0a980dbc2d131fceeecdf3b.tar.gz
OneRoll-5cfe48265ebad0ffa0a980dbc2d131fceeecdf3b.zip
-remove memory leaks
-delete created objects
Diffstat (limited to 'node')
-rw-r--r--node/countexecutenode.cpp9
-rw-r--r--node/countexecutenode.h1
-rw-r--r--node/dicerollernode.cpp8
-rw-r--r--node/dicerollernode.h3
-rw-r--r--node/executionnode.cpp10
-rw-r--r--node/explosedicenode.cpp9
-rw-r--r--node/explosedicenode.h1
-rw-r--r--node/listsetrollnode.cpp8
-rw-r--r--node/listsetrollnode.h1
-rw-r--r--node/rerolldicenode.cpp10
-rw-r--r--node/rerolldicenode.h28
-rw-r--r--node/scalaroperatornode.cpp18
-rw-r--r--node/scalaroperatornode.h3
13 files changed, 95 insertions, 14 deletions
diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp
index 281fc80..1050efc 100644
--- a/node/countexecutenode.cpp
+++ b/node/countexecutenode.cpp
@@ -4,7 +4,7 @@
CountExecuteNode::CountExecuteNode()
- : m_scalarResult(new ScalarResult())
+ : m_scalarResult(new ScalarResult()),m_validator(NULL)
{
m_result = m_scalarResult;
}
@@ -12,6 +12,13 @@ void CountExecuteNode::setValidator(Validator* validator)
{
m_validator = validator;
}
+CountExecuteNode::~CountExecuteNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ }
+}
void CountExecuteNode::run(ExecutionNode *previous)
{
diff --git a/node/countexecutenode.h b/node/countexecutenode.h
index c7ecdfd..519403b 100644
--- a/node/countexecutenode.h
+++ b/node/countexecutenode.h
@@ -16,6 +16,7 @@ public:
* @brief CountExecuteNode
*/
CountExecuteNode();
+ virtual ~CountExecuteNode();
/**
* @brief run
* @param previous
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index 1fd1a2f..f32a033 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -33,11 +33,9 @@
/// \brief DiceRollerNode::DiceRollerNode
//////////////////////////////////////////////////
DiceRollerNode::DiceRollerNode(quint64 faces)
- : m_faces(faces),m_myDiceResult(new DiceResult())
+ : m_faces(faces),m_diceResult(new DiceResult())
{
- m_mutex=new QMutex();
- m_result=m_myDiceResult;
-
+ m_result=m_diceResult;
}
void DiceRollerNode::run(ExecutionNode* previous)
{
@@ -55,7 +53,7 @@ void DiceRollerNode::run(ExecutionNode* previous)
Die* die = new Die();
die->setFaces(m_faces);
die->roll();
- m_myDiceResult->insertResult(die);
+ m_diceResult->insertResult(die);
}
if(NULL!=m_nextNode)
{
diff --git a/node/dicerollernode.h b/node/dicerollernode.h
index d50fe95..744a4b5 100644
--- a/node/dicerollernode.h
+++ b/node/dicerollernode.h
@@ -36,8 +36,7 @@ public:
private:
quint64 m_diceCount;
quint64 m_faces; /// faces
- DiceResult* m_myDiceResult;
- QMutex* m_mutex;
+ DiceResult* m_diceResult;
};
#endif // DICEROLLERNODE_H
diff --git a/node/executionnode.cpp b/node/executionnode.cpp
index 8bcd6e4..343e8d9 100644
--- a/node/executionnode.cpp
+++ b/node/executionnode.cpp
@@ -8,6 +8,16 @@ ExecutionNode::ExecutionNode()
ExecutionNode::~ExecutionNode()
{
+ if(NULL!=m_result)
+ {
+ delete m_result;
+ m_result = NULL;
+ }
+ if(NULL!=m_nextNode)
+ {
+ delete m_nextNode;
+ m_nextNode = NULL;
+ }
}
Result* ExecutionNode::getResult()
diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp
index 42b3c2d..4eae270 100644
--- a/node/explosedicenode.cpp
+++ b/node/explosedicenode.cpp
@@ -1,7 +1,7 @@
#include "explosedicenode.h"
ExploseDiceNode::ExploseDiceNode()
- : m_diceResult(new DiceResult())
+ : m_diceResult(new DiceResult()),m_validator(NULL)
{
m_result = m_diceResult;
}
@@ -33,6 +33,13 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
}
}
+ExploseDiceNode::~ExploseDiceNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ }
+}
void ExploseDiceNode::setValidator(Validator* val)
{
m_validator = val;
diff --git a/node/explosedicenode.h b/node/explosedicenode.h
index b00af1a..f5d0f6e 100644
--- a/node/explosedicenode.h
+++ b/node/explosedicenode.h
@@ -13,6 +13,7 @@ class ExploseDiceNode : public ExecutionNode
{
public:
ExploseDiceNode();
+ virtual ~ExploseDiceNode();
virtual void run(ExecutionNode* previous = NULL);
virtual void setValidator(Validator* );
virtual QString toString()const;
diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp
index 3ab9a69..777f7b0 100644
--- a/node/listsetrollnode.cpp
+++ b/node/listsetrollnode.cpp
@@ -6,6 +6,14 @@ ListSetRollNode::ListSetRollNode()
{
m_result = m_stringResult;
}
+ListSetRollNode::~ListSetRollNode()
+{
+ if(NULL!=m_diceResult)
+ {
+ delete m_diceResult;
+ m_diceResult =NULL;
+ }
+}
QStringList ListSetRollNode::getList()
{
diff --git a/node/listsetrollnode.h b/node/listsetrollnode.h
index 26fb378..c7925b8 100644
--- a/node/listsetrollnode.h
+++ b/node/listsetrollnode.h
@@ -12,6 +12,7 @@ class ListSetRollNode : public ExecutionNode
{
public:
ListSetRollNode();
+ virtual ~ListSetRollNode();
virtual void run(ExecutionNode* previous = NULL);
virtual QString toString()const;
virtual qint64 getPriority() const;
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index 81b5e01..a7cc8c4 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -2,10 +2,18 @@
RerollDiceNode::RerollDiceNode()
- : m_myDiceResult(new DiceResult()),m_adding(false)
+ : m_myDiceResult(new DiceResult()),m_adding(false),m_validator(NULL)
{
m_result=m_myDiceResult;
}
+RerollDiceNode::~RerollDiceNode()
+{
+ if(NULL!=m_validator)
+ {
+ delete m_validator;
+ m_validator = NULL;
+ }
+}
void RerollDiceNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
diff --git a/node/rerolldicenode.h b/node/rerolldicenode.h
index 4674a3e..a97e448 100644
--- a/node/rerolldicenode.h
+++ b/node/rerolldicenode.h
@@ -12,16 +12,44 @@ class RerollDiceNode : public ExecutionNode
{
public:
+ /**
+ * @brief The ReRollMode enum
+ */
enum ReRollMode {EQUAL,LESSER,GREATER};
+ /**
+ * @brief RerollDiceNode
+ */
RerollDiceNode();
+ /**
+ * @brief ~RerollDiceNode
+ */
+ virtual ~RerollDiceNode();
+ /**
+ * @brief run
+ * @param previous
+ */
virtual void run(ExecutionNode* previous);
+ /**
+ * @brief setValidator
+ */
virtual void setValidator(Validator* );
+ /**
+ * @brief toString
+ * @return
+ */
virtual QString toString()const;
+ /**
+ * @brief setAddingMode
+ */
virtual void setAddingMode(bool);
+ /**
+ * @brief getPriority
+ * @return
+ */
virtual qint64 getPriority() const;
private:
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index 95fd077..34eb6b8 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -15,6 +15,14 @@ ScalarOperatorNode::ScalarOperatorNode()
m_result = m_scalarResult;
}
+ScalarOperatorNode::~ScalarOperatorNode()
+{
+ if(NULL!=m_internalNode)
+ {
+ delete m_internalNode;
+ m_internalNode = NULL;
+ }
+}
void ScalarOperatorNode::run(ExecutionNode* previous)
{
@@ -43,7 +51,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
m_internalNode->getResult()->setPrevious(previousResult);
}
- switch(m_myOperator)
+ switch(m_operator)
{
case PLUS:
m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
@@ -74,7 +82,7 @@ bool ScalarOperatorNode::setOperatorChar(QChar c)
{
if(m_scalarOperationList.contains(c))
{
- m_myOperator = m_scalarOperationList.value(c);
+ m_operator = m_scalarOperationList.value(c);
return true;
}
return false;
@@ -110,10 +118,14 @@ QString ScalarOperatorNode::toString() const
}
qint64 ScalarOperatorNode::getPriority() const
{
- if((m_myOperator==PLUS)||(m_myOperator==MINUS))
+ if((m_operator==PLUS)||(m_operator==MINUS))
+ {
return 1;
+ }
else
+ {
return 2;
+ }
}
void ScalarOperatorNode::generateDotTree(QString& s)
{
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index a67e296..7193118 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -12,6 +12,7 @@ class ScalarOperatorNode : public ExecutionNode
public:
enum ScalarOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION};
ScalarOperatorNode();
+ virtual ~ScalarOperatorNode();
virtual void run(ExecutionNode*);
bool setOperatorChar(QChar c);
void setInternalNode(ExecutionNode* node);
@@ -28,7 +29,7 @@ private:
qint64 multiple(qint64,qint64);
private:
- ScalarOperator m_myOperator;
+ ScalarOperator m_operator;
ExecutionNode* m_internalNode;
QMap<QChar,ScalarOperator> m_scalarOperationList;
ScalarResult* m_scalarResult;