Skip to content

Commit

Permalink
Deallocate in destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
markummitchell-tu committed Jul 9, 2019
1 parent df079c9 commit a001eb3
Show file tree
Hide file tree
Showing 28 changed files with 172 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/Background/BackgroundStateContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ BackgroundStateContext::BackgroundStateContext(MainWindow &mainWindow) :
completeRequestedStateTransitionIfExists();
}

BackgroundStateContext::~BackgroundStateContext()
{
qDeleteAll (m_states);
}

void BackgroundStateContext::close()
{
LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateContext::close";
Expand Down
3 changes: 3 additions & 0 deletions src/Background/BackgroundStateContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BackgroundStateContext
/// Single constructor
BackgroundStateContext(MainWindow &mainWindow);

/// Destructor deallocates memory
~BackgroundStateContext();

/// Open Document is being closed so remove the background
void close();

Expand Down
1 change: 1 addition & 0 deletions src/Checker/Checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Checker::Checker(QGraphicsScene &scene) :

Checker::~Checker()
{
m_gridLines.clear ();
}

void Checker::adjustPolarAngleRanges (const DocumentModelCoords &modelCoords,
Expand Down
8 changes: 1 addition & 7 deletions src/CoordSystem/CoordSystemContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ CoordSystemContext::~CoordSystemContext()
{
LOG4CPP_INFO_S ((*mainCat)) << "CoordSystemContext::~CoordSystemContext";

for (int i = 0; i < m_coordSystems.count(); i++) {
CoordSystem *coordSystem = m_coordSystems.at (i);
delete coordSystem;
}

m_coordSystems.clear ();
m_coordSystemIndex = 0;
qDeleteAll (m_coordSystems);
}

void CoordSystemContext::addCoordSystems(unsigned int numberCoordSystemToAdd)
Expand Down
1 change: 1 addition & 0 deletions src/DigitizeState/DigitizeStateContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ DigitizeStateContext::DigitizeStateContext(MainWindow &mainWindow,

DigitizeStateContext::~DigitizeStateContext()
{
qDeleteAll (m_states);
}

QString DigitizeStateContext::activeCurve () const
Expand Down
5 changes: 5 additions & 0 deletions src/Dlg/DlgSettingsExportFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ DlgSettingsExportFormat::DlgSettingsExportFormat(MainWindow &mainWindow) :
DlgSettingsAbstractBase (tr ("Export Format"),
"DlgSettingsExportFormat",
mainWindow),
m_validatorFunctionsPointsEvenlySpacing (nullptr),
m_validatorRelationsPointsEvenlySpacing (nullptr),
m_modelExportBefore (nullptr),
m_modelExportAfter (nullptr),
m_haveFunction (false),
Expand All @@ -70,6 +72,9 @@ DlgSettingsExportFormat::DlgSettingsExportFormat(MainWindow &mainWindow) :
DlgSettingsExportFormat::~DlgSettingsExportFormat()
{
LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::~DlgSettingsExportFormat";

delete m_validatorFunctionsPointsEvenlySpacing;
delete m_validatorRelationsPointsEvenlySpacing;
}

void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout, int &row)
Expand Down
17 changes: 17 additions & 0 deletions src/Dlg/DlgSettingsGridDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ DlgSettingsGridDisplay::DlgSettingsGridDisplay(MainWindow &mainWindow) :
DlgSettingsAbstractBase (tr ("Grid Display"),
"DlgSettingsGridDisplay",
mainWindow),
m_validatorCountX (nullptr),
m_validatorStartX (nullptr),
m_validatorStepX (nullptr),
m_validatorStopX (nullptr),
m_validatorCountY (nullptr),
m_validatorStartY (nullptr),
m_validatorStepY (nullptr),
m_validatorStopY (nullptr),
m_scenePreview (nullptr),
m_viewPreview (nullptr),
m_modelGridDisplayBefore (nullptr),
Expand All @@ -45,6 +53,15 @@ DlgSettingsGridDisplay::DlgSettingsGridDisplay(MainWindow &mainWindow) :
DlgSettingsGridDisplay::~DlgSettingsGridDisplay()
{
LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::~DlgSettingsGridDisplay";

delete m_validatorCountX;
delete m_validatorStartX;
delete m_validatorStepX;
delete m_validatorStopX;
delete m_validatorCountY;
delete m_validatorStartY;
delete m_validatorStepY;
delete m_validatorStopY;
}

void DlgSettingsGridDisplay::createDisplayCommon (QGridLayout *layout, int &row)
Expand Down
19 changes: 19 additions & 0 deletions src/Dlg/DlgSettingsGridRemoval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ DlgSettingsGridRemoval::DlgSettingsGridRemoval(MainWindow &mainWindow) :
DlgSettingsAbstractBase (tr ("Grid Removal"),
"DlgSettingsGridRemoval",
mainWindow),
m_validatorCloseDistance (nullptr),
m_validatorCountX (nullptr),
m_validatorStartX (nullptr),
m_validatorStepX (nullptr),
m_validatorStopX (nullptr),
m_validatorCountY (nullptr),
m_validatorStartY (nullptr),
m_validatorStepY (nullptr),
m_validatorStopY (nullptr),
m_scenePreview (nullptr),
m_viewPreview (nullptr),
m_modelGridRemovalBefore (nullptr),
Expand All @@ -50,6 +59,16 @@ DlgSettingsGridRemoval::DlgSettingsGridRemoval(MainWindow &mainWindow) :
DlgSettingsGridRemoval::~DlgSettingsGridRemoval()
{
LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::~DlgSettingsGridRemoval";

delete m_validatorCloseDistance;
delete m_validatorCountX;
delete m_validatorStartX;
delete m_validatorStepX;
delete m_validatorStopX;
delete m_validatorCountY;
delete m_validatorStartY;
delete m_validatorStepY;
delete m_validatorStopY;
}

void DlgSettingsGridRemoval::createOptionalSaveDefault (QHBoxLayout * /* layout */)
Expand Down
1 change: 1 addition & 0 deletions src/Geometry/GeometryStrategyContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GeometryStrategyContext::GeometryStrategyContext()

GeometryStrategyContext::~GeometryStrategyContext()
{
qDeleteAll (m_strategies);
}

void GeometryStrategyContext::calculateGeometry (const Points &points,
Expand Down
1 change: 1 addition & 0 deletions src/Geometry/GeometryWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ GeometryWindow::GeometryWindow (MainWindow *mainWindow) :

GeometryWindow::~GeometryWindow()
{
delete m_model;
}

void GeometryWindow::clear ()
Expand Down
5 changes: 5 additions & 0 deletions src/Grid/GridLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ GridLines::GridLines()
{
}

GridLines::~GridLines()
{
qDeleteAll (m_gridLinesContainer);
}

void GridLines::add (GridLine *gridLine)
{
m_gridLinesContainer.push_back (gridLine);
Expand Down
3 changes: 3 additions & 0 deletions src/Grid/GridLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class GridLines
/// Single constructor
GridLines();

/// Destructor deallocates memory
~GridLines();

/// Add specified grid line. Ownership of all allocated QGraphicsItems is passed to new GridLine
void add (GridLine *gridLine);

Expand Down
1 change: 1 addition & 0 deletions src/Transformation/TransformationStateContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TransformationStateContext::TransformationStateContext(QGraphicsScene &scene,

TransformationStateContext::~TransformationStateContext()
{
qDeleteAll (m_states);
}

bool TransformationStateContext::isGnuplot() const
Expand Down
9 changes: 8 additions & 1 deletion src/Tutorial/TutorialStateAxisPoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
#include "TutorialStateContext.h"

TutorialStateAxisPoints::TutorialStateAxisPoints (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_previous (nullptr),
m_next (nullptr)
{
}

Expand Down
9 changes: 8 additions & 1 deletion src/Tutorial/TutorialStateChecklistWizardAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
#include "TutorialStateContext.h"

TutorialStateChecklistWizardAbstract::TutorialStateChecklistWizardAbstract (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_text3 (nullptr),
m_previous (nullptr)
{
}

Expand Down
1 change: 1 addition & 0 deletions src/Tutorial/TutorialStateChecklistWizardLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TutorialStateChecklistWizardLines::TutorialStateChecklistWizardLines (TutorialStateContext &context) :
TutorialStateChecklistWizardAbstract (context)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateChecklistWizardLines::TutorialStateChecklistWizardLines";
}

void TutorialStateChecklistWizardLines::begin ()
Expand Down
1 change: 1 addition & 0 deletions src/Tutorial/TutorialStateChecklistWizardPoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TutorialStateChecklistWizardPoints::TutorialStateChecklistWizardPoints (TutorialStateContext &context) :
TutorialStateChecklistWizardAbstract (context)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateChecklistWizardPoints::TutorialStateChecklistWizardPoints";
}

void TutorialStateChecklistWizardPoints::begin ()
Expand Down
11 changes: 10 additions & 1 deletion src/Tutorial/TutorialStateColorFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
#include "TutorialStateContext.h"

TutorialStateColorFilter::TutorialStateColorFilter (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_text3 (nullptr),
m_text4 (nullptr),
m_back (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateColorFilter::TutorialStateColorFilter";
}

void TutorialStateColorFilter::begin ()
Expand Down
5 changes: 5 additions & 0 deletions src/Tutorial/TutorialStateContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ TutorialStateContext::TutorialStateContext (TutorialDlg &tutorialDlg) :
createTimer ();
}

TutorialStateContext::~TutorialStateContext ()
{
qDeleteAll (m_states);
}

void TutorialStateContext::createStates ()
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateContext::createStates";
Expand Down
3 changes: 3 additions & 0 deletions src/Tutorial/TutorialStateContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class TutorialStateContext : public QObject
/// Single constructor
TutorialStateContext(TutorialDlg &tutorialDlg);

/// Destructor deallocates memory
~TutorialStateContext();

/// Request a transition to the specified state from the current state. A timer is used. This assumes TutorialStateContext
/// is NOT on the stack - probably since an external event (mouse click, ...) resulted in a callback to the current state
void requestDelayedStateTransition (TutorialState tutorialState);
Expand Down
12 changes: 11 additions & 1 deletion src/Tutorial/TutorialStateCurveSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@
#include "TutorialStateContext.h"

TutorialStateCurveSelection::TutorialStateCurveSelection (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_text3 (nullptr),
m_previous (nullptr),
m_colorFilter (nullptr),
m_next (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::TutorialStateCurveSelection";
}

void TutorialStateCurveSelection::begin ()
Expand Down
11 changes: 10 additions & 1 deletion src/Tutorial/TutorialStateCurveType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@
#include "TutorialStateCurveType.h"

TutorialStateCurveType::TutorialStateCurveType (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_previous (nullptr),
m_nextLines (nullptr),
m_nextPoints (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::TutorialStateCurveType";
}

void TutorialStateCurveType::begin ()
Expand Down
9 changes: 8 additions & 1 deletion src/Tutorial/TutorialStateIntroduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
#include "TutorialStateIntroduction.h"

TutorialStateIntroduction::TutorialStateIntroduction (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_next (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateIntroduction::TutorialStateIntroduction";
}

void TutorialStateIntroduction::begin ()
Expand Down
2 changes: 1 addition & 1 deletion src/Tutorial/TutorialStateIntroduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TutorialStateIntroduction : public TutorialStateAbstractBase
public:
/// Single constructor
TutorialStateIntroduction (TutorialStateContext &context);

virtual void begin ();
virtual void end ();

Expand Down
11 changes: 10 additions & 1 deletion src/Tutorial/TutorialStatePointMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
#include "TutorialStatePointMatch.h"

TutorialStatePointMatch::TutorialStatePointMatch (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_text3 (nullptr),
m_previous (nullptr),
m_next (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStatePointMatch::TutorialStatePointMatch";
}

void TutorialStatePointMatch::begin ()
Expand Down
10 changes: 9 additions & 1 deletion src/Tutorial/TutorialStateSegmentFill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@
#include "TutorialStateSegmentFill.h"

TutorialStateSegmentFill::TutorialStateSegmentFill (TutorialStateContext &context) :
TutorialStateAbstractBase (context)
TutorialStateAbstractBase (context),
m_title (nullptr),
m_background (nullptr),
m_text0 (nullptr),
m_text1 (nullptr),
m_text2 (nullptr),
m_previous (nullptr),
m_next (nullptr)
{
LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateSegmentFill::TutorialStateSegmentFill";
}

void TutorialStateSegmentFill::begin ()
Expand Down
Loading

0 comments on commit a001eb3

Please sign in to comment.