From 17fdaf6bd602ca0a99bca9e4d4c0be00d39e3079 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 9 May 2019 16:11:15 -0400 Subject: [PATCH] ListModel.clear(): Do nothing if already no data --- harmonyqml/backend/model/list_model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/harmonyqml/backend/model/list_model.py b/harmonyqml/backend/model/list_model.py index 5d37e41c..53e6caed 100644 --- a/harmonyqml/backend/model/list_model.py +++ b/harmonyqml/backend/model/list_model.py @@ -357,6 +357,9 @@ class ListModel(QAbstractListModel): @pyqtSlot() def clear(self) -> None: + if not self._data: + return + # Reimplemented for performance reasons (begin/endRemoveRows) self.beginRemoveRows(QModelIndex(), 0, len(self)) self._data.clear()