Description

Referece to the source level should be fixed by FReplaceObjectRefsArchive, but it is not working because ArIsModifyingWeakAndStrongReferences is not set.
It can be fixed by setting the flag.

class FReplaceObjectRefsArchive : public FArchiveUObject
{
public:
	FReplaceObjectRefsArchive(UObject* InRoot, const TMap<TObjectPtr<UObject>,TObjectPtr<UObject>>& InObjectsToReplace)
		: Root(InRoot)
		, ObjectsToReplace(InObjectsToReplace)
	{
		// Don't gather transient actor references
		SetIsPersistent(true);

		// Don't trigger serialization of compilable assets
		SetShouldSkipCompilingAssets(true);

		ArIgnoreOuterRef = true;
		ArIsObjectReferenceCollector = true;
		ArShouldSkipBulkData = true;
		ArIsModifyingWeakAndStrongReferences = true;  // Add this line
Steps to Reproduce

1. Open the editor
2. Create a new level with Empty Open World template
3. Place 2 or more static mesh actors
4. Uncheck IsSpatiallyLoaded flag for one of those actors via detail pane
4. Group all placed static mesh actors
5. Save the level
6. Quit the editor
7. Run WorldPartitionRenameDuplicateBuilder
Exsample command line is :

[EnginePath] [ProjectPath] [LevelPath] -run=WorldPartitionBuilderCommandlet -SCCProvider=None -builder=WorldPartitionRenameDuplicateBuilder -NewPackage=/Game/P_DuplicatedMap

Result:

Commandlet fails with the following error :

// Some comments here
LogWindows: Error: Can't save C:/Unreal Projects/TestRename/Content/__ExternalActors__/Maps/RenameTest/RenameAfter2/C/5V/Q16E1DRFEGG891LZT94PVW.uasset: Graph is linked to object World /Game/Maps/RenameTest2/RenameBase.RenameBase (GroupActors) in external map
Callstack

UnrealEditor-CoreUObject.dll!`anonymous namespace'::ValidateIllegalReferences() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage2.cpp:635]
UnrealEditor-CoreUObject.dll!`anonymous namespace'::ValidateImports() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage2.cpp:847]
UnrealEditor-CoreUObject.dll!`anonymous namespace'::SaveHarvestedRealms() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage2.cpp:2643]
UnrealEditor-CoreUObject.dll!`anonymous namespace'::InnerSave() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage2.cpp:2901]
UnrealEditor-CoreUObject.dll!UPackage::Save2() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage2.cpp:3051]
UnrealEditor-CoreUObject.dll!UPackage::Save() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage.cpp:39]
UnrealEditor-CoreUObject.dll!UPackage::SavePackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\SavePackage.cpp:60]
UnrealEditor-UnrealEd.dll!UWorldPartitionBuilder::SavePackages() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\WorldPartition\WorldPartitionBuilder.cpp:374]
UnrealEditor-UnrealEd.dll!<lambda_018e382c78e648c11720af2a5b27c854>::operator()() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\WorldPartition\WorldPartitionRenameDuplicateBuilder.cpp:299]
UnrealEditor-UnrealEd.dll!UWorldPartitionRenameDuplicateBuilder::RunInternal() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\WorldPartition\WorldPartitionRenameDuplicateBuilder.cpp:377]
UnrealEditor-UnrealEd.dll!UWorldPartitionBuilder::Run() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\WorldPartition\WorldPartitionBuilder.cpp:320]
UnrealEditor-UnrealEd.dll!UWorldPartitionBuilder::RunBuilder() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\WorldPartition\WorldPartitionBuilder.cpp:127]
UnrealEditor-UnrealEd.dll!UWorldPartitionBuilderCommandlet::Main() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Commandlets\WorldPartitionBuilderCommandlet.cpp:109]
UnrealEditor-Cmd.exe!FEngineLoop::PreInitPostStartupScreen() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4127]
UnrealEditor-Cmd.exe!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:140]
UnrealEditor-Cmd.exe!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:107]
UnrealEditor-Cmd.exe!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:244]
UnrealEditor-Cmd.exe!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:284]
UnrealEditor-Cmd.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
KERNEL32.DLL!UnknownFunction []
ntdll.dll!UnknownFunction []

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-198830 in the post.

0
Login to Vote

Unresolved
CreatedOct 24, 2023
UpdatedFeb 13, 2024