diff --git a/tools/rosbag/src/rosbag/bag.py b/tools/rosbag/src/rosbag/bag.py index 6a37dd6ae2..80e75d026c 100644 --- a/tools/rosbag/src/rosbag/bag.py +++ b/tools/rosbag/src/rosbag/bag.py @@ -1044,8 +1044,11 @@ def __str__(self): msg_count = 0 for connection in connections: - for chunk in self._chunks: - msg_count += chunk.connection_counts.get(connection.id, 0) + if self._chunks: + for chunk in self._chunks: + msg_count += chunk.connection_counts.get(connection.id, 0) + else: + msg_count += len(self._connection_indexes.get(connection.id, [])) topic_msg_counts[topic] = msg_count if self._connection_indexes_read: