From 49d8253892ef152c2d0afb1d7f968c0182b183fa Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Fri, 3 May 2013 12:54:39 -0500 Subject: [PATCH] Issue #1638 Fixed VizDisplayPane dispose and resize methods Change-Id: I2bd4e703302a8645cdb2b43e13f87ed0732e386c Former-commit-id: da052caf2b27ef4359fa9eb270a64759c9fe7f0b [formerly 200537abab77a03055176a8c154e6845e8951426] [formerly 2e96868c084e5f5c60955eafe75816131d3d3968] [formerly e7ea79782ca2d2942677cf962f36b8391a84e5ce [formerly 2e96868c084e5f5c60955eafe75816131d3d3968 [formerly 0272170330da06169c9f59ac77fd9ab1d5a124a1]]] Former-commit-id: e7ea79782ca2d2942677cf962f36b8391a84e5ce Former-commit-id: c13c73a4e61527049067a13f7f02828790481dcf [formerly f7f7e2256f71aedf0fe10662b5e80e8acd0d0cc0] Former-commit-id: 94778a69ad5ca785cf237739bc71dfc1cee05592 --- .../raytheon/viz/ui/panes/VizDisplayPane.java | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/panes/VizDisplayPane.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/panes/VizDisplayPane.java index faa2e1f86e..bd977944c2 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/panes/VizDisplayPane.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/panes/VizDisplayPane.java @@ -206,7 +206,7 @@ public class VizDisplayPane implements IDisplayPane { this.canvas.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { - VizDisplayPane.this.dispose(); + VizDisplayPane.this.disposePane(); } }); // set the renderable display @@ -378,12 +378,7 @@ public class VizDisplayPane implements IDisplayPane { return target; } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.gl.IDisplayPane#dispose() - */ - public void dispose() { + private void disposePane() { synchronized (this) { DrawCoordinatorJob.getInstance().unregisterPane(this.container, this); @@ -403,6 +398,21 @@ public class VizDisplayPane implements IDisplayPane { } } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.core.gl.IDisplayPane#dispose() + */ + public void dispose() { + disposePane(); + + if (canvas.isDisposed() == false) { + // Dispose was called outside of our own canvas listener so + // destroy the canvas composite so the pane disappears + canvasComp.dispose(); + } + } + protected void draw(final boolean actualDraw) { if (renderableDisplay == null) { @@ -809,20 +819,28 @@ public class VizDisplayPane implements IDisplayPane { * Resize the pane */ protected void resize() { - if (canvas == null || canvas.isDisposed()) { - return; + synchronized (this) { + // Schedule this to run so resize can finish if doing multiple panes and + // only called once if layout changing a lot + VizApp.runAsync(new Runnable() { + @Override + public void run() { + if (canvas == null || canvas.isDisposed()) { + return; + } + + target.resize(); + + Rectangle clientArea = canvas.getClientArea(); + if (renderableDisplay != null) { + renderableDisplay.calcPixelExtent(clientArea); + zoomLevel = renderableDisplay + .recalcZoomLevel(renderableDisplay + .getDimensions()); + } + } + }); } - - target.resize(); - - Rectangle clientArea = canvas.getClientArea(); - - if (renderableDisplay != null) { - renderableDisplay.calcPixelExtent(clientArea); - zoomLevel = renderableDisplay.recalcZoomLevel(renderableDisplay - .getDimensions()); - } - refresh(); } /*