2002/08/10 03:05:05
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:49:58 +0000 (06:49 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:49:58 +0000 (06:49 +0000)
darcs-hash:20040130064958-2ba56-de16123eca818dcf983257cd0e15b7fbb7676b64.gz

CHANGES
src/org/xwt/plat/Win32.cc
src/org/xwt/plat/Win32.java

diff --git a/CHANGES b/CHANGES
index bc6be02..e93b512 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 
 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
+
 
index a286863..67ba8b3 100644 (file)
@@ -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);
index 6a74222..3e647ac 100644 (file)
@@ -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;