Skip to content

Commit 3b9b3f3

Browse files
author
Roberto De Ioris
committed
more robust subclassing api
1 parent 1d7cc53 commit 3b9b3f3

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Blueprint/UEPyEdGraph.h"
4242
#include "Fbx/UEPyFbx.h"
4343
#include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2.h"
44+
#include "Editor/BlueprintGraph/Public/BlueprintActionDatabase.h"
4445
#endif
4546

4647

@@ -1109,14 +1110,17 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) {
11091110
return nullptr;
11101111
}
11111112
else {
1113+
UE_LOG(LogPython, Warning, TEXT("Preparing for overwriting class %s ..."), UTF8_TO_TCHAR(name));
11121114
is_overwriting = true;
11131115
}
11141116

11151117
if (is_overwriting && new_object->Children) {
11161118
UField *u_field = new_object->Children;
11171119
while (u_field) {
11181120
if (u_field->IsA<UFunction>()) {
1121+
UE_LOG(LogPython, Warning, TEXT("removing function %s"), *u_field->GetName());
11191122
new_object->RemoveFunctionFromFunctionMap((UFunction *)u_field);
1123+
FLinkerLoad::InvalidateExport(u_field);
11201124
}
11211125
u_field = u_field->Next;
11221126
}
@@ -1147,8 +1151,8 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) {
11471151

11481152
new_object->ClassCastFlags = parent->ClassCastFlags;
11491153

1150-
if (!is_overwriting)
1151-
new_object->Bind();
1154+
1155+
new_object->Bind();
11521156
new_object->StaticLink(true);
11531157

11541158
// it could be a class update
@@ -1158,10 +1162,22 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) {
11581162
new_object->ClassDefaultObject = nullptr;
11591163
}
11601164

1165+
#if WITH_EDITOR
1166+
new_object->PostEditChange();
1167+
#endif
1168+
11611169
new_object->GetDefaultObject()->PostInitProperties();
11621170

1171+
#if WITH_EDITOR
1172+
new_object->PostLinkerChange();
1173+
#endif
1174+
11631175
new_object->AssembleReferenceTokenStream();
11641176

1177+
#if WITH_EDITOR
1178+
FBlueprintActionDatabase::Get().RefreshClassActions(new_object);
1179+
#endif
1180+
11651181
return new_object;
11661182
}
11671183

@@ -2896,13 +2912,27 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
28962912
u_class->Children = function;
28972913
u_class->AddFunctionToFunctionMap(function);
28982914

2915+
u_class->Bind();
28992916
u_class->StaticLink(true);
29002917

29012918
// regenerate CDO
29022919
u_class->GetDefaultObject()->RemoveFromRoot();
29032920
u_class->GetDefaultObject()->ConditionalBeginDestroy();
29042921
u_class->ClassDefaultObject = nullptr;
2922+
2923+
#if WITH_EDITOR
2924+
u_class->PostEditChange();
2925+
#endif
2926+
29052927
u_class->GetDefaultObject()->PostInitProperties();
29062928

2929+
#if WITH_EDITOR
2930+
u_class->PostLinkerChange();
2931+
#endif
2932+
2933+
#if WITH_EDITOR
2934+
FBlueprintActionDatabase::Get().RefreshClassActions(u_class);
2935+
#endif
2936+
29072937
return function;
29082938
}

0 commit comments

Comments
 (0)