Skip to content

Commit

Permalink
Memory cleanup on object destruction.
Browse files Browse the repository at this point in the history
Appropriately release memory on object destruction.
  • Loading branch information
hmendoza2001 committed May 23, 2015
1 parent db010b2 commit fb498d8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions GLWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ GLWidget::GLWidget(QWidget* parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), p
GLWidget::~GLWidget()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
delete mRenderTimer;
delete mFrameRateTimer;
delete atmosphere;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
11 changes: 10 additions & 1 deletion IconModelMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@ IconModelMgr::~IconModelMgr()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mInstance = NULL;
int i = 0;

//release icon/image data
for (i = 0; i < mIconList.size(); i++)
{
delete mIconList[i].image;
}
mIconList.clear();

#ifdef USING_ASSIMP
//release model data
for (int i = 0; i < mModelList.size(); i++)
for (i = 0; i < mModelList.size(); i++)
{
const struct aiScene* scene = (const struct aiScene*)mModelList[i].modelData;
aiReleaseImport(scene);
}
mModelList.clear();
#endif
}

Expand Down
18 changes: 16 additions & 2 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
VolumeTool* volumeTool = new VolumeTool(mVolumeToolButton, mVolumeWindow);
MeasuringTool* measuringTool = new MeasuringTool(mMeasuringToolButton, mMeasuringWindow);


toolMgr->addTool(pathTool);
toolMgr->addTool(volumeTool);
toolMgr->addTool(measuringTool);
Expand Down Expand Up @@ -122,12 +121,27 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* Destructor.
* Destructor. Releases allocated memory.
*/
MainWindow::~MainWindow()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
delete ui;
delete mPathWindow;
delete mVolumeWindow;
delete mMeasuringWindow;
delete mPlacesWindow;
delete mTrackInfoWindow;
delete mPathVolumeWindow;
delete mAboutWindow;
delete mFileIO;
delete mShapefileReader;

delete mViewModeToolButton;
delete mPathToolButton;
delete mVolumeToolButton;
delete mMeasuringToolButton;

mInstance = NULL;
}

Expand Down
7 changes: 7 additions & 0 deletions ToolMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ ToolMgr::ToolMgr()
ToolMgr::~ToolMgr()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
//release all data
for (int i = 0; i < mToolList.size(); i++)
{
delete mToolList[i];
}
mToolList.clear();

mInstance = NULL;
}

Expand Down
1 change: 1 addition & 0 deletions TrackInfoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ TrackInfoWindow::~TrackInfoWindow()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
delete ui;
delete mUpdateTimer;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
1 change: 1 addition & 0 deletions VolumeTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ VolumeTool::VolumeTool(QToolButton* toolButton, QDialog* dialog) : Tool("Volume"
VolumeTool::~VolumeTool()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
delete mWorldObject;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
8 changes: 8 additions & 0 deletions WorldObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ WorldObjectMgr::WorldObjectMgr()
WorldObjectMgr::~WorldObjectMgr()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
//release all object data
for (int i = 0; i < mWorldObjectList.size(); i++)
{
delete mWorldObjectList[i];
}
mWorldObjectList.clear();
delete mExpireTimer;

mInstance = NULL;
}

Expand Down

0 comments on commit fb498d8

Please sign in to comment.