Commit 4b83d131 authored by Martin Walch's avatar Martin Walch

Fix warning "item has already been added to this scene"

When starting the game, exactly 8 identical warnings appear:

> QGraphicsScene::addItem: item has already been added to this scene

Their origin lies in the ScoreSprite constructor, which instantiates
several QGraphicsTextItems, passing itself as parent. Afterwards each
of them is explicitely added to the same scene as the ScoreSprite using
scene->addItem. However, this is redundant because passing the
ScoreSprite as parent already makes the new QGraphicsTextItems part of
the same scene. Hence the warning.

REVIEW:127869
parent 64fc85ad
......@@ -39,13 +39,9 @@ ScoreSprite::ScoreSprite(const QString &id, ThemeManager *theme, int advancePeri
{
// Create all sub sprites
mName = new QGraphicsTextItem(this);
scene->addItem(mName);
mPoints = new QGraphicsTextItem(this);
scene->addItem(mPoints);
mScore = new QGraphicsTextItem(this);
scene->addItem(mScore);
mGames = new QGraphicsTextItem(this);
scene->addItem(mGames);
mInput = new PixmapSprite(QLatin1String("scoreinput"), theme, advancePeriod, 0, scene);
if (!mInput) qCCritical(LSKAT_LOG) << "Cannot load sprite " << "scoreinput";
mInput->setParentItem(this);
......
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