Просмотр исходного кода

Managed resources are now properly cleaned up on domain finalization
Command queue shutdown no longer cares about the thread

Marko Pintera 11 лет назад
Родитель
Сommit
098594dddd

+ 1 - 8
BansheeCore/Include/BsCommandQueue.h

@@ -296,14 +296,7 @@ namespace BansheeEngine
 		{ }
 		{ }
 
 
 		~CommandQueue() 
 		~CommandQueue() 
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-		}
+		{ }
 
 
 		/**
 		/**
 		 * @copydoc CommandQueueBase::queueReturn
 		 * @copydoc CommandQueueBase::queueReturn

+ 1 - 5
Inspector.txt

@@ -3,11 +3,7 @@ Update GUIFoldout with sub styles
 
 
 Test if drag and dropping scene objects works with object and resource fields. Especially custom resources and components.
 Test if drag and dropping scene objects works with object and resource fields. Especially custom resources and components.
 
 
-Restore widget layout save/load methods
-Fix issue that happens when GUI element is destroyed and tries to access a previously deleted object
-Fix unreleased core objects
-Restore other commented out managed code
-Get InspectorWindow to show up in main window again
+There might be an issue with unreleased TransientMeshes (or MeshHeap) after editor widgets are docked (to test disable layout loading, dock manually and then close)
 
 
 Test custom resources:
 Test custom resources:
  - Can I load them? (Will likely need ProjectLIbrary::load)
  - Can I load them? (Will likely need ProjectLIbrary::load)

+ 2 - 0
MBansheeEngine/Program.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Diagnostics;
 using System.Diagnostics;
 
 
@@ -143,5 +144,6 @@ namespace BansheeEngine
             else
             else
                 Debug.Log("New value: " + prop2.GetValue<DbgSerzCls>().anotherValue2);
                 Debug.Log("New value: " + prop2.GetValue<DbgSerzCls>().anotherValue2);
         }
         }
+
     }
     }
 }
 }

+ 2 - 0
SBansheeEngine/Include/BsManagedResource.h

@@ -18,6 +18,8 @@ namespace BansheeEngine
 		static ManagedResourcePtr createEmpty();
 		static ManagedResourcePtr createEmpty();
 
 
 	private:
 	private:
+		friend class ScriptManagedResource;
+
 		ManagedResource(MonoObject* managedInstance);
 		ManagedResource(MonoObject* managedInstance);
 		void destroy_internal();
 		void destroy_internal();
 
 

+ 8 - 0
SBansheeEngine/Source/BsScriptManagedResource.cpp

@@ -5,6 +5,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
 #include "BsMonoManager.h"
 #include "BsManagedResource.h"
 #include "BsManagedResource.h"
+#include "BsResources.h"
 #include "BsException.h"
 #include "BsException.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -30,6 +31,13 @@ namespace BansheeEngine
 	void ScriptManagedResource::_onManagedInstanceDeleted()
 	void ScriptManagedResource::_onManagedInstanceDeleted()
 	{
 	{
 		mManagedInstance = nullptr;
 		mManagedInstance = nullptr;
+		
+		if (mResource != nullptr && mResource.isLoaded())
+		{
+			mResource->mManagedInstance = nullptr;
+			gResources().unload(mResource);
+		}
+
 		ScriptResourceManager::instance().destroyScriptResource(this);
 		ScriptResourceManager::instance().destroyScriptResource(this);
 	}
 	}