Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions unreal/Puerts/Source/JsEnv/Private/JSGeneratedClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
#include "JSWidgetGeneratedClass.h"
#include "JSLogger.h"

// UE 5.8 deprecates REN_ForceNoResetLoaders: UObject::Rename no longer calls ResetLoaders, so the flag has no effect
// there. Earlier engines keep it, where Rename would otherwise reset the package loaders.
#if ENGINE_MAJOR_VERSION > 5 || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 8)
#define PUERTS_RENAME_FLAGS (REN_DontCreateRedirectors | REN_DoNotDirty)
#else
#define PUERTS_RENAME_FLAGS (REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders)
#endif

#define OLD_METHOD_PREFIX "__puerts_old__"
#define MIXIN_METHOD_SUFFIX "__puerts_mixin__"

Expand Down Expand Up @@ -101,8 +109,7 @@ void UJSGeneratedClass::Override(v8::Isolate* Isolate, UClass* Class, UFunction*
}
// UE_LOG(LogTemp, Error, TEXT("replace %s of %s"), *Super->GetName(), *Class->GetName());
//同一Outer下的同名对象只能有一个...
Super->Rename(*FString::Printf(TEXT("%s%s"), TEXT(OLD_METHOD_PREFIX), *Super->GetName()), Class,
REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders);
Super->Rename(*FString::Printf(TEXT("%s%s"), TEXT(OLD_METHOD_PREFIX), *Super->GetName()), Class, PUERTS_RENAME_FLAGS);
Class->AddFunctionToFunctionMap(Super, Super->GetFName());
// UE_LOG(LogTemp, Error, TEXT("rename to %s"), *Super->GetName());
}
Expand Down Expand Up @@ -317,7 +324,7 @@ void UJSGeneratedClass::Restore(UClass* Class)
{
JGF->RemoveFromRoot();
}
JGF->Rename(nullptr, OrphanedClass, REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders);
JGF->Rename(nullptr, OrphanedClass, PUERTS_RENAME_FLAGS);
FLinkerLoad::InvalidateExport(JGF);
}
else
Expand All @@ -337,8 +344,7 @@ void UJSGeneratedClass::Restore(UClass* Class)
if (Function->GetName().StartsWith(TEXT(OLD_METHOD_PREFIX)))
{
Class->RemoveFunctionFromFunctionMap(Function);
Function->Rename(*Function->GetName().Mid(strlen(OLD_METHOD_PREFIX)), Class,
REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders);
Function->Rename(*Function->GetName().Mid(strlen(OLD_METHOD_PREFIX)), Class, PUERTS_RENAME_FLAGS);
Class->AddFunctionToFunctionMap(Function, Function->GetFName());
}
}
Expand Down Expand Up @@ -379,3 +385,5 @@ void UJSGeneratedClass::Release()
Constructor.Reset();
Prototype.Reset();
}

#undef PUERTS_RENAME_FLAGS
18 changes: 14 additions & 4 deletions unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
#include "Framework/Application/SlateApplication.h"
#include "Misc/MessageDialog.h"

// UE 5.8 deprecates REN_ForceNoResetLoaders: UObject::Rename no longer calls ResetLoaders, so the flag has no effect
// there. Earlier engines keep it, where Rename would otherwise reset the package loaders.
#if ENGINE_MAJOR_VERSION > 5 || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 8)
#define PUERTS_RENAME_FLAGS (REN_DontCreateRedirectors | REN_DoNotDirty)
#else
#define PUERTS_RENAME_FLAGS (REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders)
#endif

#define LOCTEXT_NAMESPACE "UPEBlueprintAsset"

DEFINE_LOG_CATEGORY_STATIC(PuertsEditorModule, Log, All);
Expand Down Expand Up @@ -556,8 +564,8 @@ void UPEBlueprintAsset::AddFunction(FName InName, bool IsVoid, FPEGraphPinType I
UEdGraph* ExistingGraph = FindObject<UEdGraph>(Blueprint, *(InName.ToString()));
if (ExistingGraph)
{
ExistingGraph->Rename(*FString::Printf(TEXT("%s%s"), *ExistingGraph->GetName(), TEXT("__Removed")), nullptr,
REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders);
ExistingGraph->Rename(
*FString::Printf(TEXT("%s%s"), *ExistingGraph->GetName(), TEXT("__Removed")), nullptr, PUERTS_RENAME_FLAGS);
}

UK2Node_CustomEvent* EventNode = FEdGraphSchemaAction_K2NewNode::SpawnNode<UK2Node_CustomEvent>(EventGraph,
Expand Down Expand Up @@ -608,8 +616,8 @@ void UPEBlueprintAsset::AddFunction(FName InName, bool IsVoid, FPEGraphPinType I
UEdGraph* ExistingGraph = FindObject<UEdGraph>(Blueprint, *(InName.ToString()));
if (ExistingGraph)
{
ExistingGraph->Rename(*FString::Printf(TEXT("%s%s"), *ExistingGraph->GetName(), TEXT("__Removed")), nullptr,
REN_DontCreateRedirectors | REN_DoNotDirty | REN_ForceNoResetLoaders);
ExistingGraph->Rename(
*FString::Printf(TEXT("%s%s"), *ExistingGraph->GetName(), TEXT("__Removed")), nullptr, PUERTS_RENAME_FLAGS);
}
}
FunctionGraph = FBlueprintEditorUtils::CreateNewGraph(Blueprint,
Expand Down Expand Up @@ -1397,3 +1405,5 @@ void UPEBlueprintAsset::Save()
}
FunctionAdded.Empty();
}

#undef PUERTS_RENAME_FLAGS