fix memory leaks in VirtualWindwoCleanup and MainWindowCleanup

This commit is contained in:
Vincent Wei
2020-03-06 10:31:31 +08:00
parent b718a9a0aa
commit 243f24d0a3
+10 -12
View File
@@ -4014,19 +4014,18 @@ BOOL GUIAPI VirtualWindowCleanup (HWND hVirtWnd)
{
PVIRTWIN pVirtWin;
if (!MG_IS_DESTROYED_VIRT_WINDOW (hVirtWnd)) {
_WRN_PRINTF ("Unexpected call: Window(%p) not destroyed yet! "
if (!(pVirtWin = getVirtWinIfDestroyed (hVirtWnd))) {
_WRN_PRINTF ("Unexpected call: Virtual window (%p) not destroyed yet! "
"Please call DestroyVirtualWindow() first\n", hVirtWnd);
return FALSE;
}
if (!getMsgQueueIfWindowInThisThread (hVirtWnd)) {
if (!getMsgQueueIfMainWindowInThisThread ((PMAINWIN)pVirtWin)) {
_WRN_PRINTF ("Unexpected call: Virtual window (%p) was not created "
"in current thread!\n", pVirtWin);
return FALSE;
}
pVirtWin = (PVIRTWIN)hVirtWnd;
_DBG_PRINTF ("window(%p), caption(%s)\n", pVirtWin, pVirtWin->spCaption);
#ifdef __THREADX__
/* to avoid threadx keep pVirtWin's value, which will lead to wrong way */
memset (pVirtWin, 0xcc, sizeof(VIRTWIN));
@@ -4097,21 +4096,20 @@ BOOL GUIAPI MainWindowCleanup (HWND hMainWnd)
{
PMAINWIN pMainWin;
if (!MG_IS_DESTROYED_MAIN_WINDOW (hMainWnd)) {
_WRN_PRINTF ("Unexpected call: Window(%p) not destroyed yet! "
if (!(pMainWin = getMainWinIfDestroyed (hMainWnd))) {
_WRN_PRINTF ("Unexpected call: Main window (%p) not destroyed yet! "
"Please call DestroyMainualWindow() first\n", hMainWnd);
return FALSE;
}
#ifdef _MGHAVE_VIRTUAL_WINDOW
if (!getMsgQueueIfWindowInThisThread (hMainWnd)) {
if (!getMsgQueueIfMainWindowInThisThread (pMainWin)) {
_WRN_PRINTF ("Unexpected call: Main window (%p) was not created "
"in current thread!\n", pMainWin);
return FALSE;
}
#endif
pMainWin = (PMAINWIN)hMainWnd;
_DBG_PRINTF ("window(%p), caption(%s)\n", pMainWin, pMainWin->spCaption);
#ifdef __THREADX__
/* to avoid threadx keep pMainWin's value, which will lead to wrong way */
memset (pMainWin, 0xcc, sizeof (MAINWIN));