Sfoglia il codice sorgente

Bugfix: Fixing more issues relating to scripting
- Missed a few stops to issue a GC barrier
- Fixed a memory leak with script scene objects

BearishSun 7 anni fa
parent
commit
f6de1399f4

+ 2 - 2
Source/SBansheeEditor/Wrappers/BsScriptEditorSettings.cpp

@@ -219,8 +219,8 @@ namespace bs
 			outputTimeStamps.set(i, recentProjects[i].accessTimestamp);
 		}
 
-		*paths = outputPaths.getInternal();
-		*timeStamps = outputPaths.getInternal();
+		MonoUtil::referenceCopy(paths, (MonoObject*)outputPaths.getInternal());
+		MonoUtil::referenceCopy(timeStamps, (MonoObject*)outputPaths.getInternal());
 	}
 
 	void ScriptEditorSettings::internal_SetRecentProjects(MonoArray* paths, MonoArray* timeStamps)

+ 3 - 3
Source/SBansheeEditor/Wrappers/BsScriptSelection.cpp

@@ -57,7 +57,7 @@ namespace bs
 			sceneObjectArray.set(i, sceneMonoObject);
 		}
 
-		*selection = sceneObjectArray.getInternal();
+		MonoUtil::referenceCopy(selection, (MonoObject*)sceneObjectArray.getInternal());
 	}
 
 	void ScriptSelection::internal_SetSceneObjectSelection(MonoArray* selection)
@@ -93,7 +93,7 @@ namespace bs
 		for (UINT32 i = 0; i < (UINT32)uuids.size(); i++)
 			uuidArray.set(i, ScriptUUID::box(uuids[i]));
 
-		*selection = uuidArray.getInternal();
+		MonoUtil::referenceCopy(selection, (MonoObject*)uuidArray.getInternal());
 	}
 
 	void ScriptSelection::internal_SetResourceUUIDSelection(MonoArray* selection)
@@ -119,7 +119,7 @@ namespace bs
 			pathArray.set(i, monoString);
 		}
 
-		*selection = pathArray.getInternal();
+		MonoUtil::referenceCopy(selection, (MonoObject*)pathArray.getInternal());
 	}
 
 	void ScriptSelection::internal_SetResourcePathSelection(MonoArray* selection)

+ 1 - 1
Source/SBansheeEngine/Wrappers/BsScriptManagedResource.cpp

@@ -76,7 +76,7 @@ namespace bs
 	{
 		mGCHandle = 0;
 		
-		if (!assemblyRefresh)
+		if (!assemblyRefresh || mResource->isDestroyed())
 		{
 			// The only way this method should be reachable is when Resource::unload is called, which means the resource
 			// has had to been already freed. Even if all managed instances are released ManagedResource itself holds the last

+ 1 - 3
Source/SBansheeEngine/Wrappers/BsScriptResource.h

@@ -109,9 +109,7 @@ namespace bs
 		void _onManagedInstanceDeleted(bool assemblyRefresh) override
 		{
 			this->freeManagedInstance();
-
-			if(!assemblyRefresh)
-				this->destroy();
+			this->destroy();
 		}
 
 		ResourceHandle<ResType> mResource;

+ 1 - 1
Source/SBansheeEngine/Wrappers/BsScriptSceneObject.cpp

@@ -398,7 +398,7 @@ namespace bs
 
 	void ScriptSceneObject::_onManagedInstanceDeleted(bool assemblyRefresh)
 	{
-		if (!assemblyRefresh)
+		if (!assemblyRefresh || mSceneObject.isDestroyed(true))
 			ScriptGameObjectManager::instance().destroyScriptSceneObject(this);
 		else
 			freeManagedInstance();