Suspend all windows locks before the control is passed to the

application.
Also fixed some bugs in dce.c
This commit is contained in:
Francois Boisvert 1999-04-02 10:34:43 +00:00 committed by Alexandre Julliard
parent 03b5529ab4
commit d96bc15580
4 changed files with 59 additions and 7 deletions

View File

@ -13,6 +13,7 @@
#include "user.h" #include "user.h"
#include "queue.h" #include "queue.h"
#include "debug.h" #include "debug.h"
#include "win.h"
/********************************************************************** /**********************************************************************
@ -22,7 +23,15 @@ static LRESULT WINAPI CALLBACK_CallWndProc( WNDPROC16 proc, HWND16 hwnd,
UINT16 msg, WPARAM16 wParam, UINT16 msg, WPARAM16 wParam,
LPARAM lParam ) LPARAM lParam )
{ {
return proc( hwnd, msg, wParam, lParam ); LRESULT retvalue;
int iWndsLocks;
/* To avoid any deadlocks, all the locks on the windows structures
must be suspended before the control is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
retvalue = proc( hwnd, msg, wParam, lParam );
WIN_RestoreWndsLock(iWndsLocks);
return retvalue;
} }

View File

@ -227,7 +227,8 @@ static INT DCE_ReleaseDC( DCE* dce )
*/ */
BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate) BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
{ {
WND* wndScope = pWnd->parent; WND* wndScope = WIN_LockWndPtr(pWnd->parent);
WND *pDesktop = WIN_GetDesktop();
BOOL bRet = FALSE; BOOL bRet = FALSE;
if( wndScope ) if( wndScope )
@ -260,10 +261,10 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
continue; continue;
} }
if( !Options.desktopGeometry && wndCurrent == WIN_GetDesktop() ) if( !Options.desktopGeometry && wndCurrent == pDesktop )
{ {
/* don't bother with fake desktop */ /* don't bother with fake desktop */
WIN_ReleaseDesktop(); WIN_ReleaseWndPtr(wndCurrent);
continue; continue;
} }
@ -306,6 +307,7 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
bRet = TRUE; bRet = TRUE;
} }
} }
WIN_ReleaseWndPtr(wnd);
break; break;
} }
xoffset += wnd->rectClient.left; xoffset += wnd->rectClient.left;
@ -315,7 +317,9 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
WIN_ReleaseWndPtr(wndCurrent); WIN_ReleaseWndPtr(wndCurrent);
} }
} /* dce list */ } /* dce list */
WIN_ReleaseWndPtr(wndScope);
} }
WIN_ReleaseDesktop();
return bRet; return bRet;
} }

View File

@ -2766,9 +2766,19 @@ BOOL16 WINAPI EnumWindows16( WNDENUMPROC16 lpEnumFunc, LPARAM lParam )
for (ppWnd = list; *ppWnd; ppWnd++) for (ppWnd = list; *ppWnd; ppWnd++)
{ {
LRESULT lpEnumFuncRetval;
int iWndsLocks = 0;
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue; if (!IsWindow((*ppWnd)->hwndSelf)) continue;
if (!lpEnumFunc( (*ppWnd)->hwndSelf, lParam )) break;
/* To avoid any deadlocks, all the locks on the windows
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam);
WIN_RestoreWndsLock(iWndsLocks);
if (!lpEnumFuncRetval) break;
} }
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
WIN_ReleaseDesktop(); WIN_ReleaseDesktop();
@ -2806,10 +2816,20 @@ BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
for (ppWnd = list; *ppWnd; ppWnd++) for (ppWnd = list; *ppWnd; ppWnd++)
{ {
LRESULT funcRetval;
int iWndsLocks = 0;
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue; if (!IsWindow((*ppWnd)->hwndSelf)) continue;
if (QUEUE_GetQueueTask((*ppWnd)->hmemTaskQ) != hTask) continue; if (QUEUE_GetQueueTask((*ppWnd)->hmemTaskQ) != hTask) continue;
if (!func( (*ppWnd)->hwndSelf, lParam )) break;
/* To avoid any deadlocks, all the locks on the windows
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
funcRetval = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
if (!funcRetval) break;
} }
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
WIN_ReleaseDesktop(); WIN_ReleaseDesktop();
@ -2841,11 +2861,20 @@ static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC16 func,
for ( ; *ppWnd; ppWnd++) for ( ; *ppWnd; ppWnd++)
{ {
int iWndsLocks = 0;
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue; if (!IsWindow((*ppWnd)->hwndSelf)) continue;
/* Build children list first */ /* Build children list first */
childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL ); childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL );
/* To avoid any deadlocks, all the locks on the windows
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
ret = func( (*ppWnd)->hwndSelf, lParam ); ret = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
if (childList) if (childList)
{ {
if (ret) ret = WIN_EnumChildWindows( childList, func, lParam ); if (ret) ret = WIN_EnumChildWindows( childList, func, lParam );

View File

@ -118,9 +118,17 @@ BOOL WINPROC_Init(void)
static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg, static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam ) WPARAM wParam, LPARAM lParam )
{ {
LRESULT retvalue;
int iWndsLocks;
TRACE(relay, "(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n", TRACE(relay, "(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
proc, hwnd, SPY_GetMsgName(msg), wParam, lParam ); proc, hwnd, SPY_GetMsgName(msg), wParam, lParam );
return proc( hwnd, msg, wParam, lParam ); /* To avoid any deadlocks, all the locks on the windows structures
must be suspended before the control is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
retvalue = proc( hwnd, msg, wParam, lParam );
WIN_RestoreWndsLock(iWndsLocks);
return retvalue;
} }
@ -2156,7 +2164,9 @@ LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1) if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
return 0; return 0;
result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam ); result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam );
return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result ); return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result );
} }