diff --git a/picard/log.py b/picard/log.py index 90e6c19fe..b5595fa69 100644 --- a/picard/log.py +++ b/picard/log.py @@ -119,17 +119,15 @@ class TailLogger(QtCore.QObject): def contents(self, prev=-1): with self._queue_lock: - # If log queue is empty, return - if not self._log_queue: - return [] - offset, length = _calculate_bounds(prev, self._log_queue[0].pos, self._log_queue[-1].pos, len(self._log_queue)) + if self._log_queue: + offset, length = _calculate_bounds(prev, self._log_queue[0].pos, self._log_queue[-1].pos, len(self._log_queue)) - if offset >= 0: - return (self._log_queue[i] for i in range(offset, length)) - # If offset < 0, there is a discontinuity in the queue positions - # Use a slower approach to get the new content. - else: - return (x for x in self._log_queue if x.pos > prev) + if offset >= 0: + yield from (self._log_queue[i] for i in range(offset, length)) + # If offset < 0, there is a discontinuity in the queue positions + # Use a slower approach to get the new content. + else: + yield from (x for x in self._log_queue if x.pos > prev) def clear(self): with self._queue_lock: