safe delete

This commit is contained in:
Anthony Calosa
2017-03-10 08:49:35 +08:00
parent 44926393ac
commit 88d1c29621
2 changed files with 25 additions and 3 deletions
+2
View File
@@ -2102,6 +2102,7 @@ public:
int resolve(); int resolve();
const string getMenuText(); const string getMenuText();
AALibraryBottom * clone() const; AALibraryBottom * clone() const;
~AALibraryBottom();
}; };
//Copier. ActivatedAbility //Copier. ActivatedAbility
@@ -2115,6 +2116,7 @@ public:
int resolve(); int resolve();
const string getMenuText(); const string getMenuText();
AACopier * clone() const; AACopier * clone() const;
~AACopier();
}; };
//phaseout //phaseout
class AAPhaseOut: public ActivatedAbility class AAPhaseOut: public ActivatedAbility
+23 -3
View File
@@ -1543,7 +1543,15 @@ const string AALibraryBottom::getMenuText()
AALibraryBottom * AALibraryBottom::clone() const AALibraryBottom * AALibraryBottom::clone() const
{ {
return NEW AALibraryBottom(*this); AALibraryBottom * a = NEW AALibraryBottom(*this);
if(andAbility)
a->andAbility = andAbility->clone();
return a;
}
AALibraryBottom::~AALibraryBottom()
{
SAFE_DELETE(andAbility);
} }
//AACopier //AACopier
@@ -1687,7 +1695,15 @@ const string AACopier::getMenuText()
AACopier * AACopier::clone() const AACopier * AACopier::clone() const
{ {
return NEW AACopier(*this); AACopier * a = NEW AACopier(*this);
if(andAbility)
a->andAbility = andAbility->clone();
return a;
}
AACopier::~AACopier()
{
SAFE_DELETE(andAbility);
} }
//phaseout //phaseout
@@ -4295,10 +4311,14 @@ ostream& AACloner::toString(ostream& out) const
AACloner * AACloner::clone() const AACloner * AACloner::clone() const
{ {
return NEW AACloner(*this); AACloner * a = NEW AACloner(*this);
if(andAbility)
a->andAbility = andAbility->clone();
return a;
} }
AACloner::~AACloner() AACloner::~AACloner()
{ {
SAFE_DELETE(andAbility);
} }
// Cast/Play Restriction modifier // Cast/Play Restriction modifier