From: megacz Date: Fri, 30 Jan 2004 06:49:58 +0000 (+0000) Subject: 2002/08/10 03:05:05 X-Git-Tag: RC3~1570 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=6e071bf7f88e5468cbd841aa6d4dc1792ff017e1 2002/08/10 03:05:05 darcs-hash:20040130064958-2ba56-de16123eca818dcf983257cd0e15b7fbb7676b64.gz --- diff --git a/CHANGES b/CHANGES index bc6be02..e93b512 100644 --- a/CHANGES +++ b/CHANGES @@ -356,4 +356,6 @@ 09-Aug megacz SpecialBoxProperty.java: changed behavior of thisbox.root +09-Aug megacz Win32.java, Win32.cc: hack to avoid strange race condition in Win32 GDI + diff --git a/src/org/xwt/plat/Win32.cc b/src/org/xwt/plat/Win32.cc index a286863..67ba8b3 100644 --- a/src/org/xwt/plat/Win32.cc +++ b/src/org/xwt/plat/Win32.cc @@ -431,7 +431,6 @@ static jint scratch_h = 0; void org::xwt::plat::Win32$Win32DoubleBuffer::drawPicture(org::xwt::Picture* source0, jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2) { - org::xwt::plat::Win32$Win32Picture* source = (org::xwt::plat::Win32$Win32Picture*)source0; if (source->hasalpha) { @@ -521,6 +520,8 @@ void org::xwt::plat::Win32$Win32DoubleBuffer::fillRect(jint x, jint y, jint x2, } void org::xwt::plat::Win32$Win32Surface::blit(org::xwt::DoubleBuffer* s, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) { + // we create the DC lazily to get around some strange race condition in WinXP + if (hdc == 0) hdc = (jint)GetDC((HWND)hwnd); BitBlt((HDC)hdc, dx, dy, dx2 - dx, dy2 - dy, (HDC)(((org::xwt::plat::Win32$Win32DoubleBuffer*)s)->hdc), sx, sy, SRCCOPY); } @@ -610,7 +611,6 @@ void org::xwt::plat::Win32$Win32Surface::natInit(jboolean framed) { // GC_enable_incremental(); ShowWindow ((HWND)hwnd, SW_SHOWDEFAULT); - hdc = (jint)GetDC((HWND)hwnd); } void org::xwt::plat::Win32$Win32Surface::finalize() { /* DeleteObject((void*)hwnd); */ } @@ -655,6 +655,9 @@ void org::xwt::plat::Win32$Win32Surface::setIcon(org::xwt::Picture* p0) { int icon_width = GetSystemMetrics(SM_CXSMICON); int icon_height = GetSystemMetrics(SM_CYSMICON); + // we create the DC lazily to get around some strange race condition in WinXP + if (hdc == 0) hdc = (jint)GetDC((HWND)hwnd); + // create the bitmap HBITMAP bit = CreateCompatibleBitmap((HDC)hdc, icon_width, icon_height); HDC memdc = CreateCompatibleDC((HDC)hdc); diff --git a/src/org/xwt/plat/Win32.java b/src/org/xwt/plat/Win32.java index 6a74222..3e647ac 100644 --- a/src/org/xwt/plat/Win32.java +++ b/src/org/xwt/plat/Win32.java @@ -205,7 +205,7 @@ public class Win32 extends GCJ { boolean captured = false; public int hwnd = -1; - public int hdc = -1; + public int hdc = 0; public int current_cursor = default_cursor;