From 896bd2a13f33c82194b601b9d0716968d45c742a Mon Sep 17 00:00:00 2001 From: Reinder Feenstra Date: Fri, 6 Jan 2023 00:50:32 +0100 Subject: [PATCH] bugfix: added keepalive, to make sure object isn't deleted during destroy() call --- server/src/core/object.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/core/object.cpp b/server/src/core/object.cpp index 4a572ad3..48ac64ab 100644 --- a/server/src/core/object.cpp +++ b/server/src/core/object.cpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2019-2021 Reinder Feenstra + * Copyright (C) 2019-2021,2023 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -41,6 +41,7 @@ void Object::destroy() if(!m_dying) { m_dying = true; + auto keepAlive = shared_from_this(); // make sure object isn't deleted during destroying destroying(); onDestroying(*this); }