Browse Source

Fixed events so that unloaded libraries don't corrupt virtual tables for event connection data

BearishSun 10 years ago
parent
commit
461cc6e9ca

+ 1 - 1
BansheeCore/Source/BsMeshImportOptions.cpp

@@ -6,7 +6,7 @@ namespace BansheeEngine
 	MeshImportOptions::MeshImportOptions()
 		:mCPUReadable(false), mImportNormals(false), mImportTangents(false), 
 		mImportBlendShapes(false), mImportSkin(false), mImportAnimation(false),
-		mImportScale(0.01f)
+		mImportScale(1.0f)
 	{ }
 
 	/************************************************************************/

+ 5 - 3
BansheeUtility/Include/BsEvent.h

@@ -48,7 +48,7 @@ namespace BansheeEngine
 			while (conn != nullptr)
 			{
 				BaseConnectionData* next = conn->next;
-				bs_delete(conn);
+				bs_free(conn);
 
 				conn = next;
 			}
@@ -57,7 +57,7 @@ namespace BansheeEngine
 			while (conn != nullptr)
 			{
 				BaseConnectionData* next = conn->next;
-				bs_delete(conn);
+				bs_free(conn);
 
 				conn = next;
 			}
@@ -141,6 +141,7 @@ namespace BansheeEngine
 			}
 
 			mFreeConnections = conn;
+			mFreeConnections->~BaseConnectionData();
 		}
 
 		BaseConnectionData* mConnections;
@@ -193,7 +194,7 @@ namespace BansheeEngine
 		/**
 		* @brief	Allows direct conversion of a handle to bool.
 		*
-		* @note		This is needed because we can't directly convert to bool
+		* @note		Additional struct is needed because we can't directly convert to bool
 		*			since then we can assign pointer to bool and that's wrong.
 		*/
 		operator int Bool_struct::*() const
@@ -265,6 +266,7 @@ namespace BansheeEngine
 				connData = static_cast<ConnectionData*>(mInternalData->mFreeConnections);
 				mInternalData->mFreeConnections = connData->next;
 
+				new (connData)ConnectionData();
 				if (connData->next != nullptr)
 					connData->next->prev = nullptr;
 

+ 1 - 1
ExampleProject/Main/Main.cpp

@@ -362,7 +362,7 @@ namespace BansheeEngine
 		rightLayout->addNewElement<GUIFixedSpace>(30);
 
 		// Add a profiler overlay object that is responsible for displaying CPU and GPU profiling GUI
-		profilerOverlay = guiSO->addComponent<ProfilerOverlay>(guiCamera);
+		profilerOverlay = guiSO->addComponent<ProfilerOverlay>(guiCamera.getInternalPtr());
 
 		// Set up video mode list box
 		// First get a list of output devices