From 46aab8c1ff61220fe69af3d31aaef9e3bed98602 Mon Sep 17 00:00:00 2001 From: wangxidong Date: Thu, 15 Dec 2022 10:57:36 +0800 Subject: [PATCH] fix windows crash bugs --- .../Source/AgoraExample/AgoraVideoWidget.cpp | 7 +++++++ .../Source/AgoraExample/AgoraVideoWidget.h | 2 ++ .../Source/AgoraExample/ProcessAudioRawDataWidget.cpp | 3 +-- .../Source/AgoraExample/ProcessAudioRawDataWidget.h | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.cpp b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.cpp index cf8c59bb..88baa1c7 100644 --- a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.cpp +++ b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.cpp @@ -190,6 +190,11 @@ void UAgoraVideoWidget::onUserOffline(agora::rtc::uid_t uid, agora::rtc::USER_OF void UAgoraVideoWidget::onLeaveChannel(const agora::rtc::RtcStats& stats) { AsyncTask(ENamedThreads::GameThread, [=]() { + if (bIsDestruct) + { + UE_LOG(LogTemp, Warning, TEXT("UVideoWidget::onLeaveChannel bIsDestruct")); + return; + } UE_LOG(LogTemp, Warning, TEXT("UVideoWidget::onLeaveChannel")); agora::rtc::VideoCanvas videoCanvas; videoCanvas.view = nullptr; @@ -318,6 +323,8 @@ void UAgoraVideoWidget::NativeDestruct() { delete RtcEngineProxy; RtcEngineProxy = nullptr; + + bIsDestruct = true; } } \ No newline at end of file diff --git a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.h b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.h index 6cb0135d..994def7f 100644 --- a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.h +++ b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/AgoraVideoWidget.h @@ -140,6 +140,8 @@ class AGORAEXAMPLE_API UAgoraVideoWidget : public UBaseAgoraUserWidget, public a FSlateBrush EmptyBrush; + bool bIsDestruct = false; + void InitAgoraEngine(FString APP_ID, FString TOKEN, FString CHANNEL_NAME); void SetUpUIEvent(); diff --git a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.cpp b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.cpp index 64e65b97..01b31162 100644 --- a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.cpp +++ b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.cpp @@ -2,8 +2,7 @@ #include "ProcessAudioRawDataWidget.h" -#include -#import + void UProcessAudioRawDataWidget::InitAgoraWidget(FString APP_ID, FString TOKEN, FString CHANNEL_NAME) { InitConfig(); diff --git a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.h b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.h index 64c7fe4f..42ce99a1 100644 --- a/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.h +++ b/Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/ProcessAudioRawDataWidget.h @@ -15,6 +15,9 @@ #include "AndroidPermission/Classes/AndroidPermissionFunctionLibrary.h" #endif #include +#if PLATFORM_IOS +#import +#endif #include "ProcessAudioRawDataWidget.generated.h" using namespace agora::rtc;