tmf: TmfStatisticsModule fixes
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 7 Feb 2014 20:03:04 +0000 (15:03 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 10 Feb 2014 19:22:04 +0000 (14:22 -0500)
Following exta review comments on https://git.eclipse.org/r/#/c/19412/

Change-Id: Ie0200ee7beb6a69c450220ade97a7f5bfe570649
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/21700
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
IP-Clean: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Hudson CI
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsModule.java

index 67c580faa2a01bf4d2ec31bc563f6bb2f6810aeb..838cbe84a571f682dac50e0061c9899743ac7bdf 100644 (file)
@@ -94,12 +94,8 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
     }
 
     @Override
-    protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
-        ITmfTrace trace = getTrace();
-        if (trace == null) {
-            /* This analysis's trace should not be null when this is called */
-            throw new IllegalStateException();
-        }
+    public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
+        super.setTrace(trace);
 
         /*
          * Since these sub-analyzes are not built from an extension point, we
@@ -108,10 +104,20 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
          */
         totalsModule.setTrace(trace);
         eventTypesModule.setTrace(trace);
+    }
+
+    @Override
+    protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
+        ITmfTrace trace = getTrace();
+        if (trace == null) {
+            /* This analysis's trace should not be null when this is called */
+            throw new IllegalStateException();
+        }
 
         IStatus status1 = totalsModule.schedule();
         IStatus status2 = eventTypesModule.schedule();
-        if (!status1.isOK() || !status2.isOK()) {
+        if (!(status1.isOK() && status2.isOK())) {
+            cancelSubAnalyses();
             return false;
         }
 
@@ -136,8 +142,8 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
          * The rest of this "execute" will encompass the "execute" of the two
          * sub-analyzes.
          */
-        if (!totalsModule.waitForCompletion(monitor) ||
-                !eventTypesModule.waitForCompletion(monitor)) {
+        if (!(totalsModule.waitForCompletion(monitor) &&
+                eventTypesModule.waitForCompletion(monitor))) {
             return false;
         }
         return true;
@@ -149,8 +155,7 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
          * FIXME The "right" way to cancel state system construction is not
          * available yet...
          */
-        totalsModule.cancel();
-        eventTypesModule.cancel();
+        cancelSubAnalyses();
 
         ITmfStatistics stats = fStatistics;
         if (stats != null) {
@@ -158,6 +163,11 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
         }
     }
 
+    private void cancelSubAnalyses() {
+        totalsModule.cancel();
+        eventTypesModule.cancel();
+    }
+
     // ------------------------------------------------------------------------
     // ITmfStateSystemAnalysisModule
     // ------------------------------------------------------------------------
This page took 0.026816 seconds and 5 git commands to generate.