From 2ac7b9142bb6cd8ce4b7af14c12b6bbd2b13bf24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Mon, 6 Jun 2011 20:53:51 +0300 Subject: [PATCH] Changed the map creation to create each pixmap just once per round Just in case creating the pixmap from filename actually reads the file each time, the pixmap is created once per map creation and the same one is given to QGraphicsItem each time its used. --- seascene.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/seascene.cpp b/seascene.cpp index 50a0152..9f59b27 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -49,7 +49,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses) if (pPosition == NULL) break; - QGraphicsPixmapItem * pRock = addPixmap(QPixmap(":/pix/kari.png")); + QPixmap rockPixmap (":/pix/kari.png"); + QGraphicsPixmapItem * pRock = addPixmap(rockPixmap); pRock->setData(0,"rock"); pRock->setPos(*pPosition); delete pPosition; @@ -74,7 +75,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses) if (pPosition == NULL) break; - TimerControlledTursas * pOctopus = new TimerControlledTursas (QPixmap(":/pix/tursas.png"),100); + QPixmap octopusPixmap (":/pix/tursas.png"); + TimerControlledTursas * pOctopus = new TimerControlledTursas (octopusPixmap,100); pOctopus->setData(0,"octopus"); pOctopus->setPos(*pPosition); addItem(pOctopus); @@ -116,7 +118,8 @@ void SeaScene::spreadGhosts(int ghosts) if (pPosition == NULL) return; - QGraphicsPixmapItem * pGhost = addPixmap(QPixmap(":/pix/aave.png")); + QPixmap ghostPixmap(":/pix/aave.png"); + QGraphicsPixmapItem * pGhost = addPixmap(ghostPixmap); pGhost->setData(0,"ghost"); pGhost->setPos(*pPosition); delete pPosition; -- 1.7.9.5