tmf: Bug 490400: Leaking widgets due to incorrect cleanup in dispose()
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / ScrollView.java
index 629fbd35614af727645222ba1697d0ce63372e9d..7074aad49e5313d87d41eb25e1d1193a943fc595 100755 (executable)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
+ * Copyright (c) 2005, 2016 IBM Corporation, Ericsson
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -407,6 +407,23 @@ public class ScrollView extends Composite {
                 }
             });
         }
+
+        addDisposeListener((e) -> {
+            if (fAutoScroll != null) {
+                fAutoScroll.cancel();
+                fAutoScroll = null;
+            }
+            fViewControl = null;
+            fVertScrollBar = null;
+            fHorScrollBar = null;
+            if (fCornerControl != null) {
+                Object data = fCornerControl.getData();
+                if (data instanceof Overview) {
+                    ((Overview) data).dispose();
+                }
+            }
+            fCornerControl = null;
+        });
     }
 
     // ------------------------------------------------------------------------
@@ -423,35 +440,6 @@ public class ScrollView extends Composite {
         fViewControl.setCursor(cursor);
     }
 
-    @Override
-    public void dispose() {
-        if (fAutoScroll != null) {
-            fAutoScroll.cancel();
-            fAutoScroll = null;
-        }
-        if (fViewControl != null) {
-            fViewControl.dispose();
-        }
-        fViewControl = null;
-        if (fVertScrollBar != null) {
-            fVertScrollBar.dispose();
-        }
-        fVertScrollBar = null;
-        if (fHorScrollBar != null) {
-            fHorScrollBar.dispose();
-        }
-        fHorScrollBar = null;
-        if (fCornerControl != null) {
-            Object data = fCornerControl.getData();
-            if (data instanceof Overview) {
-                ((Overview) data).dispose();
-            }
-            fCornerControl.dispose();
-            fCornerControl = null;
-        }
-        super.dispose();
-    }
-
     @Override
     public Rectangle getClientArea() {
         Rectangle area = fViewControl.getClientArea();
This page took 0.034893 seconds and 5 git commands to generate.