crash fix
This commit is contained in:
parent
50ae90c148
commit
4186d73c88
2 changed files with 35 additions and 26 deletions
|
@ -9,6 +9,7 @@ Counter::Counter(Player *_player, int _id, const QString &_name, QColor _color,
|
|||
if (radius > Player::counterAreaWidth / 2)
|
||||
radius = Player::counterAreaWidth / 2;
|
||||
|
||||
if (player->getLocal()) {
|
||||
menu = new QMenu(name);
|
||||
aSet = new QAction(this);
|
||||
connect(aSet, SIGNAL(triggered()), this, SLOT(setCounter()));
|
||||
|
@ -27,6 +28,8 @@ Counter::Counter(Player *_player, int _id, const QString &_name, QColor _color,
|
|||
connect(aIncrement, SIGNAL(triggered()), this, SLOT(incrementCounter()));
|
||||
menu->addAction(aIncrement);
|
||||
}
|
||||
} else
|
||||
menu = 0;
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -38,12 +41,14 @@ Counter::~Counter()
|
|||
|
||||
void Counter::retranslateUi()
|
||||
{
|
||||
if (menu) {
|
||||
aSet->setText(tr("&Set counter..."));
|
||||
if (name == "life") {
|
||||
aSet->setShortcut(tr("Ctrl+L"));
|
||||
aDec->setShortcut(tr("F11"));
|
||||
aInc->setShortcut(tr("F12"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QRectF Counter::boundingRect() const
|
||||
|
@ -76,6 +81,7 @@ void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
player->client->incCounter(id, 1);
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
if (menu)
|
||||
menu->exec(event->screenPos());
|
||||
event->accept();
|
||||
} else
|
||||
|
|
|
@ -168,8 +168,10 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
|||
playerMenu->addSeparator();
|
||||
sayMenu = playerMenu->addMenu(QString());
|
||||
initSayMenu();
|
||||
} else
|
||||
} else {
|
||||
countersMenu = 0;
|
||||
sbMenu = 0;
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -602,6 +604,7 @@ void Player::addCounter(int counterId, const QString &name, QColor color, int ra
|
|||
{
|
||||
Counter *c = new Counter(this, counterId, name, color, radius, value, this);
|
||||
counters.insert(counterId, c);
|
||||
if (countersMenu)
|
||||
countersMenu->addMenu(c->getMenu());
|
||||
rearrangeCounters();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue