OSX: Fix infinite loop in waiting for lockFocusIfCanDraw=YES

There are some bug report about problems when the window is minimized.
I was able to reproduce this bug minimizing the window, hiding the dock
(using the system settings), showing the dock again, and trying to
restore the window.
This commit is contained in:
David Capello 2015-01-26 10:27:36 -03:00
parent 3745f563d0
commit 6c3b4ba805

View File

@ -121,28 +121,32 @@ static void prepare_window_for_animation(int refresh_view)
int pitch, y, x;
_unix_lock_mutex(osx_window_mutex);
while (![qd_view lockFocusIfCanDraw]);
while (!QDDone([qd_view qdPort]));
LockPortBits([qd_view qdPort]);
pitch = GetPixRowBytes(GetPortPixMap([qd_view qdPort])) / 4;
addr = (unsigned int *)GetPixBaseAddr(GetPortPixMap([qd_view qdPort])) +
((int)([osx_window frame].size.height) - gfx_quartz_window.h) * pitch;
if (refresh_view && colorconv_blitter) {
src_gfx_rect.width = gfx_quartz_window.w;
src_gfx_rect.height = gfx_quartz_window.h;
src_gfx_rect.pitch = pseudo_screen_pitch;
src_gfx_rect.data = pseudo_screen_addr;
dest_gfx_rect.pitch = pitch * 4;
dest_gfx_rect.data = addr;
colorconv_blitter(&src_gfx_rect, &dest_gfx_rect);
if ([qd_view lockFocusIfCanDraw] == YES) {
while (!QDDone([qd_view qdPort]));
LockPortBits([qd_view qdPort]);
pitch = GetPixRowBytes(GetPortPixMap([qd_view qdPort])) / 4;
addr = (unsigned int *)GetPixBaseAddr(GetPortPixMap([qd_view qdPort])) +
((int)([osx_window frame].size.height) - gfx_quartz_window.h) * pitch;
if (refresh_view && colorconv_blitter) {
src_gfx_rect.width = gfx_quartz_window.w;
src_gfx_rect.height = gfx_quartz_window.h;
src_gfx_rect.pitch = pseudo_screen_pitch;
src_gfx_rect.data = pseudo_screen_addr;
dest_gfx_rect.pitch = pitch * 4;
dest_gfx_rect.data = addr;
colorconv_blitter(&src_gfx_rect, &dest_gfx_rect);
}
for (y = gfx_quartz_window.h; y; y--) {
for (x = 0; x < gfx_quartz_window.w; x++)
*(addr + x) |= 0xff000000;
addr += pitch;
}
UnlockPortBits([qd_view qdPort]);
[qd_view unlockFocus];
}
for (y = gfx_quartz_window.h; y; y--) {
for (x = 0; x < gfx_quartz_window.w; x++)
*(addr + x) |= 0xff000000;
addr += pitch;
}
UnlockPortBits([qd_view qdPort]);
[qd_view unlockFocus];
_unix_unlock_mutex(osx_window_mutex);
}