[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14212] trunk/blender: BGE correction: AddRef() on source object of property actuator to protect against crash if the source object is deleted (bad game design anyway)

Benoit Bolsee benoit.bolsee at online.be
Sat Mar 22 15:47:43 CET 2008


Revision: 14212
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14212
Author:   ben2610
Date:     2008-03-22 15:47:42 +0100 (Sat, 22 Mar 2008)

Log Message:
-----------
BGE correction: AddRef() on source object of property actuator to protect against crash if the source object is deleted (bad game design anyway)

Modified Paths:
--------------
    trunk/blender/projectfiles_vc7/blender/src/BL_src.vcproj
    trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp

Modified: trunk/blender/projectfiles_vc7/blender/src/BL_src.vcproj
===================================================================
--- trunk/blender/projectfiles_vc7/blender/src/BL_src.vcproj	2008-03-22 13:27:34 UTC (rev 14211)
+++ trunk/blender/projectfiles_vc7/blender/src/BL_src.vcproj	2008-03-22 14:47:42 UTC (rev 14212)
@@ -548,6 +548,9 @@
 				RelativePath="..\..\..\source\blender\src\transform_manipulator.c">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\src\transform_ndofinput.c">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\src\transform_numinput.c">
 			</File>
 			<File

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp	2008-03-22 13:27:34 UTC (rev 14211)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp	2008-03-22 14:47:42 UTC (rev 14212)
@@ -52,10 +52,16 @@
 	m_exprtxt(expr),
 	m_sourceObj(sourceObj)
 {
+	// protect ourselves against someone else deleting the source object
+	// don't protect against ourselves: it would create a dead lock
+	if (m_sourceObj && m_sourceObj != GetParent())
+		m_sourceObj->AddRef();
 }
 
 SCA_PropertyActuator::~SCA_PropertyActuator()
 {
+	if (m_sourceObj && m_sourceObj != GetParent())
+		m_sourceObj->Release();
 }
 
 bool SCA_PropertyActuator::Update()





More information about the Bf-blender-cvs mailing list