winemac: Move CVDisplayLink operations out of @synchronized blocks to avoid potential deadlock.

The -fire method called by the display link callback also synchronizes on self
(while accessing the windows array).  Display link operations use a lock to
synchronize, too, and it's held while the callback is running.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2017-05-08 12:52:02 -05:00 committed by Alexandre Julliard
parent e90aaaabe6
commit 24d3795285
1 changed files with 8 additions and 4 deletions

View File

@ -218,22 +218,26 @@ - (void) dealloc
- (void) addWindow:(WineWindow*)window
{
BOOL needsStart;
@synchronized(self) {
BOOL needsStart = !_windows.count;
needsStart = !_windows.count;
[_windows addObject:window];
if (needsStart)
CVDisplayLinkStart(_link);
}
if (needsStart)
CVDisplayLinkStart(_link);
}
- (void) removeWindow:(WineWindow*)window
{
BOOL shouldStop = FALSE;
@synchronized(self) {
BOOL wasRunning = _windows.count > 0;
[_windows removeObject:window];
if (wasRunning && !_windows.count)
CVDisplayLinkStop(_link);
shouldStop = TRUE;
}
if (shouldStop)
CVDisplayLinkStop(_link);
}
- (void) fire