mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 02:13:02 -07:00
[GameScene] Sever connections properly.
Took 2 minutes Took 54 minutes
This commit is contained in:
parent
704611fc1f
commit
7c842ef350
1 changed files with 10 additions and 5 deletions
|
|
@ -44,11 +44,16 @@ GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent)
|
||||||
|
|
||||||
GameScene::~GameScene()
|
GameScene::~GameScene()
|
||||||
{
|
{
|
||||||
// Sever all incoming connections (animated item destroy-tracking) before the
|
// Sever the destroy-tracking connections before the members and base-class
|
||||||
// members below are destroyed: the base QGraphicsScene destructor destroys the
|
// teardown destroy the items. The receiver (this) cannot be matched with a
|
||||||
// remaining items, and their destroyed() signals must not reach slots that
|
// nullptr sender (QObject::disconnect forbids one) so disconnect each
|
||||||
// reference members that no longer exist.
|
// tracked sender explicitly. Otherwise, when the base QGraphicsScene destructor
|
||||||
QObject::disconnect(nullptr, nullptr, this, nullptr);
|
// destroys the remaining items, their destroyed() signals would re-enter
|
||||||
|
// removeAnimatedItem() and touch members that no longer exist.
|
||||||
|
const auto animatedSenders = animatedItems.keys();
|
||||||
|
for (QObject *sender : animatedSenders) {
|
||||||
|
disconnect(sender, &QObject::destroyed, this, &GameScene::removeAnimatedItem);
|
||||||
|
}
|
||||||
|
|
||||||
delete animationTimer;
|
delete animationTimer;
|
||||||
animationTimer = nullptr;
|
animationTimer = nullptr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue