PlayModel: do not emit the coordChanged() signal when no change occurred

This commit is contained in:
Olivier Teulière 2012-12-18 01:09:36 +01:00
parent c31b789fc5
commit 1e551207fb
3 changed files with 6 additions and 4 deletions

View file

@ -461,8 +461,7 @@ void ArbitrationWidget::updateCoordText(const Coord &iNewCoord)
void ArbitrationWidget::updatePlayModel(const QString &iText) void ArbitrationWidget::updatePlayModel(const QString &iText)
{ {
Coord coord(wfq(iText)); Coord coord(wfq(iText));
if (!(m_playModel.getCoord() == coord)) m_playModel.setCoord(coord);
m_playModel.setCoord(coord);
} }

View file

@ -26,6 +26,10 @@ INIT_LOGGER(qt, PlayModel);
void PlayModel::setCoord(const Coord &iCoord) void PlayModel::setCoord(const Coord &iCoord)
{ {
// Avoid useless work
if (iCoord == m_currCoord)
return;
m_prevCoord = m_currCoord; m_prevCoord = m_currCoord;
m_currCoord = iCoord; m_currCoord = iCoord;
emit coordChanged(iCoord, m_prevCoord); emit coordChanged(iCoord, m_prevCoord);

View file

@ -214,8 +214,7 @@ void PlayWordMediator::playWord()
void PlayWordMediator::onCoordChanged(const QString &iText) void PlayWordMediator::onCoordChanged(const QString &iText)
{ {
Coord coord(wfq(iText)); Coord coord(wfq(iText));
if (!(m_playModel.getCoord() == coord)) m_playModel.setCoord(coord);
m_playModel.setCoord(coord);
updatePointsAndState(); updatePointsAndState();
} }