changeset 3326:90dcea60577e

6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes Reviewed-by: bae, chrisphi
author miroslawzn
date Wed, 08 Dec 2010 15:15:49 -0800
parents ad7feec4413e
children 2dff913337a8
files src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h
diffstat 2 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Wed Dec 08 15:04:41 2010 -0800
+++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Wed Dec 08 15:15:49 2010 -0800
@@ -54,6 +54,7 @@
 static jclass xorCompClass;
 
 static jboolean beingShutdown = JNI_FALSE;
+static volatile LONG timeStamp = 0;
 extern CriticalSection windowMoveLock;
 
 extern "C"
@@ -90,12 +91,24 @@
     HDC oldhDC = info->hDC;
     // the hDC is NULL for offscreen surfaces - we don't store it
     // in TLS as it must be created new every time.
-    if (((oldhDC == NULL) && wsdo->window != NULL) || (info->wsdo != wsdo)) {
+
+    if( ((oldhDC == NULL) && wsdo->window != NULL) ||
+         (info->wsdo != wsdo) ||
+         (info->wsdoTimeStamp != wsdo->timeStamp) )
+    {
 
         // Init graphics state, either because this is our first time
         // using it in this thread or because this thread is now
         // dealing with a different window than it was last time.
 
+        //check extra condition:
+        //(info->wsdoTimeStamp != wsdo->timeStamp).
+        //Checking memory addresses (info->wsdo != wsdo) will not detect
+        //that wsdo points to a newly allocated structure in case
+        //that structure just got allocated at a "recycled" memory location
+        //which previously was pointed by info->wsdo
+        //see bug# 6859086
+
         // Release cached DC. We use deferred DC releasing mechanism because
         // the DC is associated with cached wsdo and component peer,
         // which may've been disposed by this time, and we have
@@ -157,7 +170,9 @@
         info->xorcolor = 0;
         info->patrop = PATCOPY;
 
+        //store the address and time stamp of newly allocated GDIWinSDOps structure
         info->wsdo = wsdo;
+        info->wsdoTimeStamp = wsdo->timeStamp;
     }
 }
 
@@ -367,6 +382,7 @@
         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
         return;
     }
+    wsdo->timeStamp = InterlockedIncrement(&timeStamp); //creation time stamp
     wsdo->sdOps.Lock = GDIWinSD_Lock;
     wsdo->sdOps.GetRasInfo = GDIWinSD_GetRasInfo;
     wsdo->sdOps.Unlock = GDIWinSD_Unlock;
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h	Wed Dec 08 15:04:41 2010 -0800
+++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h	Wed Dec 08 15:15:49 2010 -0800
@@ -148,6 +148,11 @@
  */
 struct _GDIWinSDOps {
     SurfaceDataOps      sdOps;
+    LONG                timeStamp; // creation time stamp.
+                                   // Doesn't store a real time -
+                                   // just counts creation events of this structure
+                                   // made by GDIWindowSurfaceData_initOps()
+                                   // see bug# 6859086
     jboolean            invalid;
     GetDCFunc           *GetDC;
     ReleaseDCFunc       *ReleaseDC;
@@ -192,6 +197,13 @@
 typedef struct {
     HDC         hDC;
     GDIWinSDOps *wsdo;
+    LONG        wsdoTimeStamp; // wsdo creation time stamp.
+                               // Other threads may deallocate wsdo
+                               // and then allocate a new GDIWinSDOps
+                               // structure at the same memory location.
+                               // Time stamp is the only way to detect if
+                               // wsdo got changed.
+                               // see bug# 6859086
     RECT        bounds;
     jobject     clip;
     jobject     comp;