From 7c842ef3507ac4b15c39c749daceb157dc2cbc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sat, 29 Aug 2026 11:29:16 +0200 Subject: [PATCH] [GameScene] Sever connections properly. Took 2 minutes Took 54 minutes --- cockatrice/src/game_graphics/game_scene.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/game_graphics/game_scene.cpp b/cockatrice/src/game_graphics/game_scene.cpp index 87af4c73c..43e181875 100644 --- a/cockatrice/src/game_graphics/game_scene.cpp +++ b/cockatrice/src/game_graphics/game_scene.cpp @@ -44,11 +44,16 @@ GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent) GameScene::~GameScene() { - // Sever all incoming connections (animated item destroy-tracking) before the - // members below are destroyed: the base QGraphicsScene destructor destroys the - // remaining items, and their destroyed() signals must not reach slots that - // reference members that no longer exist. - QObject::disconnect(nullptr, nullptr, this, nullptr); + // Sever the destroy-tracking connections before the members and base-class + // teardown destroy the items. The receiver (this) cannot be matched with a + // nullptr sender (QObject::disconnect forbids one) so disconnect each + // tracked sender explicitly. Otherwise, when the base QGraphicsScene destructor + // 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; animationTimer = nullptr;