If you subclass AActor and override the FEditPropertyChain& variant of PreEditChange(), a call to Super::PreEditChange(PropertyAboutToChange) will fail to compile because of C++'s [annoy and ancient] overload hiding rules.
Fix is that AActor should have a “using Super::PreEditChange;” line above the existing method declaration to bring forward both argument signatures.
More info about overload hiding: https://stackoverflow.com/questions/6727087/c\-virtual\-function\-being\-hidden
Example of errors:
3>C:\myProj\myProj\Source\myProj\MyActor.cpp(715): error C2664: 'void AActor::PreEditChange(FProperty *)': cannot convert argument 1 from 'FEditPropertyChain' to 'FProperty *'
3>C:\myProj\myProj\Source\myProj\MyActor.cpp(715): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
3>C:\myProj\Unreal\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h(2324): note: see declaration of 'AActor::PreEditChange'
3>C:\myProj\myProj\Source\myProj\MyActor.cpp(715): note: while trying to match the argument list '(FEditPropertyChain)'
Steps to Reproduce
UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()
public:
#if WITH_EDITOR
virtual void PreEditChange(FEditPropertyChain& PropertyAboutToChange) override
{
// Placeholder
static int x =0;
++x;
Super::PreEditChange(PropertyAboutToChange); // <-- Error here
}
#endif
};
Hello Phillip,
You are correct in noticing that there is no chain version of PreEditChange and probably should be, but I don’t think your suggested fix is a good idea. Support for PreEditChange(FEditPropertyChain) is currently not supported well in the engine, and there are many places that just call it directly with PreEditChange(FProperty*) so your override is unlikely to be called in most situations. UObject::PreEditChange(FEditPropertyChain) calls the single property version to work around this. If you do have a specific need to override the chain version, you should be able to avoid the compile error by calling UObject::PreEditChange(PropertyAboutToChange) directly, like how UVCamComponent does.
I definitely agree that the current state of this in the engine is not great so we will put in a JIRA to track the general problem.
Okay. We’ll just keep this change local then.