Animation Control Hang
Ulrich Czekalla
ulrich.czekalla at utoronto.ca
Tue Nov 30 11:06:39 CST 2004
ChangeLog:
Ulrich Czekalla <ulrich at codeweavers.com>
Prevent the animation thread from waiting on itself when it stops
-------------- next part --------------
Index: dlls/comctl32/animate.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/animate.c,v
retrieving revision 1.58
diff -u -r1.58 animate.c
--- dlls/comctl32/animate.c 6 Nov 2004 03:49:04 -0000 1.58
+++ dlls/comctl32/animate.c 29 Nov 2004 17:20:50 -0000
@@ -73,6 +73,7 @@
CRITICAL_SECTION cs;
HANDLE hStopEvent;
HANDLE hThread;
+ DWORD threadId;
UINT uTimer;
/* data for playing the file */
int nFromFrame;
@@ -149,14 +150,20 @@
HANDLE handle = infoPtr->hThread;
TRACE("stopping animation thread\n");
+ infoPtr->hThread = 0;
SetEvent( infoPtr->hStopEvent );
- LeaveCriticalSection(&infoPtr->cs); /* leave it a chance to run */
- WaitForSingleObject( handle, INFINITE );
- TRACE("animation thread stopped\n");
- EnterCriticalSection(&infoPtr->cs);
- CloseHandle( infoPtr->hThread );
+
+ if (infoPtr->threadId != GetCurrentThreadId())
+ {
+ LeaveCriticalSection(&infoPtr->cs); /* leave it a chance to run */
+ WaitForSingleObject( handle, INFINITE );
+ TRACE("animation thread stopped\n");
+ EnterCriticalSection(&infoPtr->cs);
+ }
+
+ CloseHandle( handle );
CloseHandle( infoPtr->hStopEvent );
- infoPtr->hThread = 0;
+ infoPtr->hStopEvent = 0;
}
if (infoPtr->uTimer) {
KillTimer(infoPtr->hwndSelf, infoPtr->uTimer);
@@ -399,7 +406,7 @@
LeaveCriticalSection(&infoPtr->cs);
/* time is in microseconds, we should convert it to milliseconds */
- if (WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0)
+ if ((event == 0) || WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0)
break;
}
return TRUE;
@@ -439,8 +446,6 @@
/* create a timer to display AVI */
infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
} else {
- DWORD threadID;
-
if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
{
infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify,
@@ -449,7 +454,7 @@
TRACE("Using an animation thread\n");
infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL );
- infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &threadID);
+ infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &infoPtr->threadId);
if(!infoPtr->hThread)
{
ERR("Could not create animation thread!\n");
More information about the wine-patches
mailing list