I have a bunch of custom cpp widget types which inherit from UPanelWidget that are used when building UI dialogs for our application. They all share a common base class whose initialization is below. (simplified for clarity)
I had a breakpoint sitting in the BeginDestroy function when I launched the editor and noticed that when the editor got to the 95% - Postloading Objects.. task it triggered the BeginDestroy function for every widget that was used in every UI dialog. This seemed odd to me as the breakpoint was inside the CDO exclusion check.
Is this normal behavior, or is how we’re handling the objects erroneous in some way?
/* Class Specifiers */
UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew, config=Engine)
/* Class initilization */
UBaseInteractive::UBaseInteractive(const FObjectInitializer& objectInitializer) : Super(objectInitializer) {
//Disallows controls from being exposed as variables in a blueprint
bIsVariable = false;
}
void UBaseInteractive::PostInitProperties() {
Super::PostInitProperties();
//Don't bind if this is the unreal CDO
if (!HasAnyFlags(RF_ClassDefaultObject)) {
OnStateChanged.AddUniqueDynamic(this, &UBaseInteractive::StateChanged_Event);
}
}
void UBaseInteractive::BeginDestroy() {
//Only need to handle if this is not the unreal CDO
if (!HasAnyFlags(RF_ClassDefaultObject)) {
OnStateChanged.Clear();
}
Super::BeginDestroy();
}