tmf: Fix context resource leak in raw event viewer
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 16 Jun 2015 21:30:45 +0000 (17:30 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 3 Jul 2015 17:05:20 +0000 (13:05 -0400)
Change-Id: I20dfb3f921d260771efee4b69abaa8d90ec9c44f
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/49466
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java

index 74d61a0867056c72a8d2a11900543a1c375666b0..c0e3c2475bc35b9e32ec83ab69aae480551d964a 100644 (file)
@@ -197,6 +197,9 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
 
     @Override
     public void dispose() {
+        if (fBottomContext != null) {
+            fBottomContext.dispose();
+        }
         PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(this);
         super.dispose();
     }
@@ -353,14 +356,20 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
             if (fLines.size() == 0) {
                 setTopRank(0);
             } else if (fLines.size() < fNumVisibleLines) {
-                fBottomContext = null;
+                if (fBottomContext != null) {
+                    fBottomContext.dispose();
+                    fBottomContext = null;
+                }
                 loadLineData();
                 fillTextArea();
                 //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
                 fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
             }
         } else {
-            fBottomContext = null;
+            if (fBottomContext != null) {
+                fBottomContext.dispose();
+                fBottomContext = null;
+            }
             fillTextArea();
             fSlider.setThumb(SLIDER_MAX);
             fSlider.setSelection(0);
@@ -430,6 +439,9 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
     }
 
     private void setTopRank(long rank) {
+        if (fBottomContext != null) {
+            fBottomContext.dispose();
+        }
         fBottomContext = fTrace.seekEvent(rank);
         if (fBottomContext == null) {
             return;
@@ -448,6 +460,9 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
     }
 
     private void setTopPosition(double ratio) {
+        if (fBottomContext != null) {
+            fBottomContext.dispose();
+        }
         fBottomContext = fTrace.seekEvent(ratio);
         if (fBottomContext == null) {
             return;
@@ -523,6 +538,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                         }
                         rank++;
                     }
+                    context.dispose();
                     long rankOffset = fLines.get(index).rank - rank;
                     for (int i = 0; i < index; i++) {
                         fLines.get(i).rank += rankOffset;
@@ -581,7 +597,10 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                 for (int i = MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
                     if (fLines.get(i).rank > rank) {
                         fLines.subList(i, fLines.size()).clear();
-                        fBottomContext = null;
+                        if (fBottomContext != null) {
+                            fBottomContext.dispose();
+                            fBottomContext = null;
+                        }
                         break;
                     }
                 }
This page took 0.04328 seconds and 5 git commands to generate.