Commit b26fefeb authored by Stefan Majewsky's avatar Stefan Majewsky

Refactoring: Simplify unnecessarily complicated deletion statements.

svn path=/trunk/KDE/kdegames/kgoldrunner/; revision=1145635
parent 1bbe0339
......@@ -136,10 +136,8 @@ KGrCanvas::~KGrCanvas()
enemyFrames->clear();
deleteAllSprites();
while (!borderRectangles.isEmpty())
delete borderRectangles.takeFirst();
while (!borderElements.isEmpty())
delete borderElements.takeFirst();
qDeleteAll(borderRectangles);
qDeleteAll(borderElements);
delete playfield;
delete tileset;
......@@ -691,13 +689,8 @@ void KGrCanvas::deleteSprite (const int spriteId)
void KGrCanvas::deleteAllSprites()
{
KGrSprite * sprite = 0;
while (! sprites->isEmpty()) {
sprite = sprites->takeFirst();
if (sprite != 0) {
delete sprite;
}
}
qDeleteAll(*sprites);
sprites->clear();
emptySprites = 0;
}
......@@ -774,10 +767,10 @@ void KGrCanvas::makeBorder ()
int tlY = topLeft.y();
int lw = imgW / lineDivider; // Line width.
while (!borderRectangles.isEmpty())
delete borderRectangles.takeFirst();
while (!borderElements.isEmpty())
delete borderElements.takeFirst();
qDeleteAll(borderRectangles);
borderRectangles.clear();
qDeleteAll(borderElements);
borderElements.clear();
// a fancy border can be specified in the SVG file; if that is unavailable,
// a simple border can be specified in the theme properties file.
......
......@@ -110,16 +110,10 @@ KGrGame::KGrGame (KGrCanvas * theView,
KGrGame::~KGrGame()
{
while (! gameList.isEmpty()) {
delete gameList.takeFirst();
}
qDeleteAll(gameList);
delete randomGen;
if (levelPlayer) {
delete levelPlayer;
}
if (recording) {
delete recording;
}
delete levelPlayer;
delete recording;
}
// Flags to control author's debugging aids.
......
......@@ -65,9 +65,8 @@ int KGrLevelPlayer::playerCount = 0;
KGrLevelPlayer::~KGrLevelPlayer()
{
while (! dugBricks.isEmpty()) {
delete dugBricks.takeFirst();
}
qDeleteAll(dugBricks);
dugBricks.clear(); //TODO: necessary?
kDebug() << "LEVEL PLAYER BEING DELETED.";
playerCount--;
......
......@@ -29,8 +29,7 @@ KGrPlayField::KGrPlayField (KGameCanvasAbstract* canvas)
KGrPlayField::~KGrPlayField()
{
// Clear all stored data.
while (!m_tilesprites.isEmpty())
delete m_tilesprites.takeFirst();
qDeleteAll(m_tilesprites);
delete m_background;
}
......@@ -77,8 +76,8 @@ void KGrPlayField::setTiles (QList<QPixmap> * tileset, const QPoint & topLeft,
Q_ASSERT (tileset);
// Clear previously cached tile data.
while (! m_tilesprites.isEmpty())
delete m_tilesprites.takeFirst();
qDeleteAll(m_tilesprites);
m_tilesprites.clear();
// Now store our tileset as a list of Pixmaps, one for each tile.
m_tileset = tileset;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment