fix view zone close

This commit is contained in:
RickyRister 2025-01-20 00:40:43 -08:00
parent 3d18196710
commit 7a688fd7a9
4 changed files with 18 additions and 7 deletions

View file

@ -2083,7 +2083,7 @@ void Player::eventShuffle(const Event_Shuffle &event)
int length = view->getCards().length();
// we want to close empty views as well
if (length == 0 || length > absStart) { // note this assumes views always start at the top of the library
view->deleteLater();
view->close();
break;
}
} else {

View file

@ -42,11 +42,20 @@ ZoneViewZone::ZoneViewZone(Player *_p,
ZoneViewZone::~ZoneViewZone()
{
emit beingDeleted();
qDebug("ZoneViewZone destructor");
}
/**
* Deletes this ZoneView and removes it from the origZone's views.
* You should normally call this method instead of deleteLater()
*/
void ZoneViewZone::close()
{
emit closed();
if (!(revealZone && !writeableRevealZone)) {
origZone->getViews().removeOne(this);
}
deleteLater();
}
QRectF ZoneViewZone::boundingRect() const

View file

@ -94,13 +94,14 @@ public:
return isReversed;
}
public slots:
void close();
void setGroupBy(CardList::SortOption _groupBy);
void setSortBy(CardList::SortOption _sortBy);
void setPileView(int _pileView);
private slots:
void zoneDumpReceived(const Response &r);
signals:
void beingDeleted();
void closed();
void optimumRectChanged();
void wheelEventReceived(QGraphicsSceneWheelEvent *event);

View file

@ -133,7 +133,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
setLayout(vbox);
connect(zone, &ZoneViewZone::optimumRectChanged, this, &ZoneViewWidget::resizeToZoneContents);
connect(zone, &ZoneViewZone::beingDeleted, this, &ZoneViewWidget::zoneDeleted);
connect(zone, &ZoneViewZone::closed, this, &ZoneViewWidget::zoneDeleted);
zone->initializeCards(cardList);
// QLabel sizes aren't taken into account until the widget is rendered.
@ -314,11 +314,12 @@ void ZoneViewWidget::handleScrollBarChange(int value)
void ZoneViewWidget::closeEvent(QCloseEvent *event)
{
disconnect(zone, &ZoneViewZone::beingDeleted, this, 0);
disconnect(zone, &ZoneViewZone::closed, this, 0);
// manually call zone->close in order to remove it from the origZones views
zone->close();
if (shuffleCheckBox.isChecked())
player->sendGameCommand(Command_Shuffle());
emit closePressed(this);
deleteLater();
zoneDeleted();
event->accept();
}