Bladeren bron

Bugfix: Native async resource import will no longer incorrectly destroy the resource before the import gets finalized, if no other handles are being held to it

BearishSun 6 jaren geleden
bovenliggende
commit
903c7c300d
3 gewijzigde bestanden met toevoegingen van 8 en 7 verwijderingen
  1. 2 6
      Source/EditorCore/Library/BsProjectLibrary.cpp
  2. 5 0
      Source/EditorCore/Library/BsProjectLibrary.h
  3. 1 1
      Source/bsf

+ 2 - 6
Source/EditorCore/Library/BsProjectLibrary.cpp

@@ -599,8 +599,7 @@ namespace bs
 							// Any access to queuedImport->resources must be locked
 							// Any access to queuedImport->resources must be locked
 							Lock lock(mutex);
 							Lock lock(mutex);
 
 
-							queuedImport->resources.push_back(QueuedImportResource("primary", resource.getInternalPtr(),
-								resource.getUUID()));
+							queuedImport->resources.push_back(QueuedImportResource("primary", resource));
 						}
 						}
 
 
 						const String uuidStr = resource.getUUID().toString();
 						const String uuidStr = resource.getUUID().toString();
@@ -730,10 +729,7 @@ namespace bs
 				// Native resources are always expected to have a handle since Resources::load was called during
 				// Native resources are always expected to have a handle since Resources::load was called during
 				// the 'import' step
 				// the 'import' step
 				if (import.native)
 				if (import.native)
-				{
-					importedResource = gResources()._getResourceHandle(entry.uuid);
-					gResources().update(importedResource, entry.resource);
-				}
+					importedResource = entry.handle;
 				else
 				else
 					importedResource = gResources()._createResourceHandle(entry.resource, entry.uuid);
 					importedResource = gResources()._createResourceHandle(entry.resource, entry.uuid);
 
 

+ 5 - 0
Source/EditorCore/Library/BsProjectLibrary.h

@@ -305,8 +305,13 @@ namespace bs
 				:name(std::move(name)), resource(std::move(resource)), uuid(uuid)
 				:name(std::move(name)), resource(std::move(resource)), uuid(uuid)
 			{ }
 			{ }
 
 
+			QueuedImportResource(String name, const HResource& handle)
+				:name(std::move(name)), resource(handle.getInternalPtr()), handle(handle), uuid(handle.getUUID())
+			{ }
+
 			String name;
 			String name;
 			SPtr<Resource> resource;
 			SPtr<Resource> resource;
+			HResource handle;
 			UUID uuid;
 			UUID uuid;
 		};
 		};
 
 

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 8d2260f3b0b3f2dd0d82f1eb26c1757cf9fc629b
+Subproject commit 477d03559a78f5f59abe309db0fc0ef7f41e864d