From 16aeb84cd35996a6b41f10cbc48a677eeccc911c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 2 Jan 2021 13:50:34 +0000 Subject: Fix potential destruction crashes (#5095) * Fix potential destruction crashes * Fix destructors accessing destroyted objects * Fix cPlayer not destroying windows (Destroyed never called) * Tentatively fixes #4608, fixes #3236, fixes #3262 - Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld() * Add missing call to OnRemoveFromWorld --- src/BlockEntities/EnderChestEntity.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/BlockEntities/EnderChestEntity.cpp') diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp index 44bfaf7d4..c5d490766 100644 --- a/src/BlockEntities/EnderChestEntity.cpp +++ b/src/BlockEntities/EnderChestEntity.cpp @@ -25,23 +25,23 @@ cEnderChestEntity::cEnderChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMe -cEnderChestEntity::~cEnderChestEntity() +void cEnderChestEntity::SendTo(cClientHandle & a_Client) { - cWindow * Window = GetWindow(); - if (Window != nullptr) - { - Window->OwnerDestroyed(); - } + // Send a dummy "number of players with chest open" packet to make the chest visible: + a_Client.SendBlockAction(m_Pos.x, m_Pos.y, m_Pos.z, 1, 0, m_BlockType); } -void cEnderChestEntity::SendTo(cClientHandle & a_Client) +void cEnderChestEntity::OnRemoveFromWorld() { - // Send a dummy "number of players with chest open" packet to make the chest visible: - a_Client.SendBlockAction(m_Pos.x, m_Pos.y, m_Pos.z, 1, 0, m_BlockType); + const auto Window = GetWindow(); + if (Window != nullptr) + { + Window->OwnerDestroyed(); + } } -- cgit v1.2.3