From cd0863d7faf0aea3c7a18cf02a6fc0aabd3292d7 Mon Sep 17 00:00:00 2001
From: Waleed El-Geresy <waleed.el-geresy@arm.com>
Date: Fri, 11 Aug 2017 16:33:49 +0100
Subject: [PATCH] revent.py: Fix handling of zero-event files

Previously the try clause worked to catch StopIteration exceptions correctly,
however upon catching the exception, another statment which set self._duration
to (last.time - first.time) was being run regardless, which defeated the point
of the try clause.

This has been fixed by introducing an else clause to contain said statement.
---
 wlauto/utils/revent.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/wlauto/utils/revent.py b/wlauto/utils/revent.py
index 619b6367..24ddb384 100644
--- a/wlauto/utils/revent.py
+++ b/wlauto/utils/revent.py
@@ -142,9 +142,10 @@ class ReventRecording(object):
                     first = last = events.next()
                 except StopIteration:
                     self._duration = 0
-                for last in events:
-                    pass
-                self._duration = (last.time - first.time).total_seconds()
+                else:
+                    for last in events:
+                        pass
+                    self._duration = (last.time - first.time).total_seconds()
             else:  # not streaming
                 if not self._events:
                     self._duration = 0