fix(collection): 收集Widget补NativeDestruct清理计时器
This commit is contained in:
@@ -11,6 +11,19 @@ void UCollectionCompleteWidget::NativeOnInitialized()
|
|||||||
Super::NativeOnInitialized();
|
Super::NativeOnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UCollectionCompleteWidget::NativeDestruct()
|
||||||
|
{
|
||||||
|
// 清理计时器:StayTimer/FadeOutTimer 的 lambda 捕获裸 this,Widget 销毁后 fire 会野指针
|
||||||
|
// (与 CollectionHUDComponent::EndPlay 同类卫生写法,防关卡切换/退 PIE 时的悬挂 timer)
|
||||||
|
if (UWorld* World = GetWorld())
|
||||||
|
{
|
||||||
|
World->GetTimerManager().ClearTimer(StayTimerHandle);
|
||||||
|
World->GetTimerManager().ClearTimer(FadeOutTimerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Super::NativeDestruct();
|
||||||
|
}
|
||||||
|
|
||||||
void UCollectionCompleteWidget::ShowComplete(const FString& Text, float DisplayDuration, float InFadeOutDuration)
|
void UCollectionCompleteWidget::ShowComplete(const FString& Text, float DisplayDuration, float InFadeOutDuration)
|
||||||
{
|
{
|
||||||
CachedFadeOutDuration = InFadeOutDuration;
|
CachedFadeOutDuration = InFadeOutDuration;
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ protected:
|
|||||||
|
|
||||||
virtual void NativeOnInitialized() override;
|
virtual void NativeOnInitialized() override;
|
||||||
|
|
||||||
|
/** Widget 销毁时清理计时器:lambda 捕获裸 this,销毁后 fire 会野指针 */
|
||||||
|
virtual void NativeDestruct() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** 停留结束 → 播放淡出动画 */
|
/** 停留结束 → 播放淡出动画 */
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ void UCollectionNotifWidget::NativeOnInitialized()
|
|||||||
Super::NativeOnInitialized();
|
Super::NativeOnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UCollectionNotifWidget::NativeDestruct()
|
||||||
|
{
|
||||||
|
// 清理计时器:StayTimer/FadeOutTimer 的 lambda 捕获裸 this,Widget 销毁后 fire 会野指针
|
||||||
|
// (与 CollectionHUDComponent::EndPlay 同类卫生写法,防关卡切换/退 PIE 时的悬挂 timer)
|
||||||
|
if (UWorld* World = GetWorld())
|
||||||
|
{
|
||||||
|
World->GetTimerManager().ClearTimer(StayTimerHandle);
|
||||||
|
World->GetTimerManager().ClearTimer(FadeOutTimerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Super::NativeDestruct();
|
||||||
|
}
|
||||||
|
|
||||||
void UCollectionNotifWidget::InitializeNotif(const FString& Text, FLinearColor TextColor,
|
void UCollectionNotifWidget::InitializeNotif(const FString& Text, FLinearColor TextColor,
|
||||||
float InFadeInDuration, float InStayDuration, float InFadeOutDuration)
|
float InFadeInDuration, float InStayDuration, float InFadeOutDuration)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ protected:
|
|||||||
|
|
||||||
virtual void NativeOnInitialized() override;
|
virtual void NativeOnInitialized() override;
|
||||||
|
|
||||||
|
/** Widget 销毁时清理计时器:lambda 捕获裸 this,销毁后 fire 会野指针 */
|
||||||
|
virtual void NativeDestruct() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** 停留结束 → 播放淡出动画 */
|
/** 停留结束 → 播放淡出动画 */
|
||||||
|
|||||||
Reference in New Issue
Block a user