fix: Prevent crash when closing window during background data processing

This commit is contained in:
yuanyuanxiang
2025-06-29 03:29:35 +08:00
parent c59232d179
commit aa34b64995
19 changed files with 106 additions and 30 deletions

View File

@@ -222,7 +222,7 @@ typedef struct CONTEXT_OBJECT
CBuffer InCompressedBuffer; // <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CBuffer InDeCompressedBuffer; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CBuffer OutCompressedBuffer;
int v1;
HWND hWnd;
HANDLE hDlg;
void *olps; // OVERLAPPEDPLUS
int CompressMethod; // ѹ<><D1B9><EFBFBD>
@@ -236,7 +236,7 @@ typedef struct CONTEXT_OBJECT
VOID InitMember(SOCKET s)
{
memset(szBuffer, 0, sizeof(char) * PACKET_LENGTH);
v1 = 0;
hWnd = NULL;
hDlg = NULL;
sClientSocket = s;
PeerName = ::GetPeerName(sClientSocket);
@@ -497,9 +497,10 @@ public:
IOCPServer* m_iocpServer;
CString m_IPAddress;
bool m_bIsClosed;
bool m_bIsProcessing;
HICON m_hIcon;
CDialogBase(UINT nIDTemplate, CWnd* pParent, IOCPServer* pIOCPServer, CONTEXT_OBJECT* pContext, int nIcon) :
m_bIsClosed(false),
m_bIsClosed(false), m_bIsProcessing(false),
m_ContextObject(pContext),
m_iocpServer(pIOCPServer),
CDialog(nIDTemplate, pParent) {
@@ -516,8 +517,17 @@ public:
public:
virtual void OnReceiveComplete(void) = 0;
// <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void MarkReceiving(bool recv = true) {
m_bIsProcessing = recv;
}
bool IsProcessing() const {
return m_bIsProcessing;
}
void OnClose() {
m_bIsClosed = TRUE;
m_bIsClosed = true;
while (m_bIsProcessing)
Sleep(200);
if(m_hIcon) DestroyIcon(m_hIcon);
m_hIcon = NULL;
CDialog::OnClose();
@@ -529,6 +539,7 @@ public:
{
delete this;
}
// ȡ<><C8A1> SOCKET <20><>ȡ<EFBFBD><C8A1><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD>
void CancelIO(){
m_bIsClosed = TRUE;