Fix command zone tax counter position after counter re-sync

This commit is contained in:
DawnFire42 2026-07-09 15:54:57 -04:00
parent aed13a242d
commit d42b7c8003
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
3 changed files with 19 additions and 0 deletions

View file

@ -242,6 +242,9 @@ void PlayerGraphicsItem::onCounterRemoved(int counterId)
if (playerMenu->getCountersMenu() && widget->getMenu()) {
playerMenu->getCountersMenu()->removeAction(widget->getMenu()->menuAction());
}
if (commandZoneGraphicsItem && CounterNames::isTaxCounter(widget->getName())) {
commandZoneGraphicsItem->unregisterTaxCounter(widget);
}
widget->delCounter();
rearrangeCounters();
}

View file

@ -160,6 +160,15 @@ void CommandZone::registerTaxCounter(AbstractCounter *counter)
connect(counter, &QObject::destroyed, this, [this, counter]() { taxCounters.removeOne(counter); });
}
void CommandZone::unregisterTaxCounter(AbstractCounter *counter)
{
if (!counter) {
return;
}
disconnect(counter, &QObject::destroyed, this, nullptr);
taxCounters.removeOne(counter);
}
void CommandZone::rearrangeTaxCounters()
{
int activeTaxCounterCount = 0;

View file

@ -89,6 +89,13 @@ public:
void setMinimumHeight(int height);
/** @brief Registers a tax counter widget for layout management. */
void registerTaxCounter(AbstractCounter *counter);
/**
* @brief Unregisters a tax counter widget from layout management.
*
* Call on removal: the widget outlives it via deleteLater(), so unregister synchronously
* to keep it out of the next layout pass.
*/
void unregisterTaxCounter(AbstractCounter *counter);
/** @brief Lays out visible tax counters vertically in the top-left corner of the command zone. */
void rearrangeTaxCounters();