jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java

Print this page
rev 5693 : 7192977: Issue in toolkit thread
Reviewed-by: skoivu, rupashka, art


 479             // null out the old data to make it collected faster
 480             oldData = null;
 481         }
 482     }
 483 
 484     public void replaceSurfaceDataLater() {
 485         Runnable r = new Runnable() {
 486             public void run() {
 487                 // Shouldn't do anything if object is disposed in meanwhile
 488                 // No need for sync as disposeAction in Window is performed
 489                 // on EDT
 490                 if (!isDisposed()) {
 491                     try {
 492                         replaceSurfaceData();
 493                     } catch (InvalidPipeException e) {
 494                     // REMIND : what do we do if our surface creation failed?
 495                     }
 496                 }
 497             }
 498         };

 499         // Fix 6255371.
 500         if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing((Component)target, r)) {
 501             postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), r));
 502         }
 503     }
 504 
 505     public boolean updateGraphicsData(GraphicsConfiguration gc) {
 506         winGraphicsConfig = (Win32GraphicsConfig)gc;
 507         try {
 508             replaceSurfaceData();
 509         } catch (InvalidPipeException e) {
 510             // REMIND : what do we do if our surface creation failed?
 511         }
 512         return false;
 513     }
 514 
 515     //This will return null for Components not yet added to a Container
 516     public ColorModel getColorModel() {
 517         GraphicsConfiguration gc = getGraphicsConfiguration();
 518         if (gc != null) {
 519             return gc.getColorModel();
 520         }
 521         else {


 603                                       bgColor, font);
 604         }
 605         return null;
 606     }
 607     public FontMetrics getFontMetrics(Font font) {
 608         return WFontMetrics.getFontMetrics(font);
 609     }
 610 
 611     private synchronized native void _dispose();
 612     protected void disposeImpl() {
 613         SurfaceData oldData = surfaceData;
 614         surfaceData = null;
 615         ScreenUpdateManager.getInstance().dropScreenSurface(oldData);
 616         oldData.invalidate();
 617         // remove from updater before calling targetDisposedPeer
 618         WToolkit.targetDisposedPeer(target, this);
 619         _dispose();
 620     }
 621 
 622     public void disposeLater() {
 623         postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), new Runnable() {
 624             public void run() {
 625                 dispose();
 626             }
 627         }));
 628     }
 629 
 630     public synchronized void setForeground(Color c) {
 631         foreground = c;
 632         _setForeground(c.getRGB());
 633     }
 634 
 635     public synchronized void setBackground(Color c) {
 636         background = c;
 637         _setBackground(c.getRGB());
 638     }
 639 
 640     /**
 641      * This method is intentionally not synchronized as it is called while
 642      * holding other locks.
 643      *




 479             // null out the old data to make it collected faster
 480             oldData = null;
 481         }
 482     }
 483 
 484     public void replaceSurfaceDataLater() {
 485         Runnable r = new Runnable() {
 486             public void run() {
 487                 // Shouldn't do anything if object is disposed in meanwhile
 488                 // No need for sync as disposeAction in Window is performed
 489                 // on EDT
 490                 if (!isDisposed()) {
 491                     try {
 492                         replaceSurfaceData();
 493                     } catch (InvalidPipeException e) {
 494                         // REMIND : what do we do if our surface creation failed?
 495                     }
 496                 }
 497             }
 498         };
 499         Component c = (Component)target;
 500         // Fix 6255371.
 501         if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
 502             postEvent(new InvocationEvent(c, r));
 503         }
 504     }
 505 
 506     public boolean updateGraphicsData(GraphicsConfiguration gc) {
 507         winGraphicsConfig = (Win32GraphicsConfig)gc;
 508         try {
 509             replaceSurfaceData();
 510         } catch (InvalidPipeException e) {
 511             // REMIND : what do we do if our surface creation failed?
 512         }
 513         return false;
 514     }
 515 
 516     //This will return null for Components not yet added to a Container
 517     public ColorModel getColorModel() {
 518         GraphicsConfiguration gc = getGraphicsConfiguration();
 519         if (gc != null) {
 520             return gc.getColorModel();
 521         }
 522         else {


 604                                       bgColor, font);
 605         }
 606         return null;
 607     }
 608     public FontMetrics getFontMetrics(Font font) {
 609         return WFontMetrics.getFontMetrics(font);
 610     }
 611 
 612     private synchronized native void _dispose();
 613     protected void disposeImpl() {
 614         SurfaceData oldData = surfaceData;
 615         surfaceData = null;
 616         ScreenUpdateManager.getInstance().dropScreenSurface(oldData);
 617         oldData.invalidate();
 618         // remove from updater before calling targetDisposedPeer
 619         WToolkit.targetDisposedPeer(target, this);
 620         _dispose();
 621     }
 622 
 623     public void disposeLater() {
 624         postEvent(new InvocationEvent(target, new Runnable() {
 625             public void run() {
 626                 dispose();
 627             }
 628         }));
 629     }
 630 
 631     public synchronized void setForeground(Color c) {
 632         foreground = c;
 633         _setForeground(c.getRGB());
 634     }
 635 
 636     public synchronized void setBackground(Color c) {
 637         background = c;
 638         _setBackground(c.getRGB());
 639     }
 640 
 641     /**
 642      * This method is intentionally not synchronized as it is called while
 643      * holding other locks.
 644      *