ListModel.clear(): Do nothing if already no data
This commit is contained in:
		@@ -357,6 +357,9 @@ class ListModel(QAbstractListModel):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @pyqtSlot()
 | 
					    @pyqtSlot()
 | 
				
			||||||
    def clear(self) -> None:
 | 
					    def clear(self) -> None:
 | 
				
			||||||
 | 
					        if not self._data:
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Reimplemented for performance reasons (begin/endRemoveRows)
 | 
					        # Reimplemented for performance reasons (begin/endRemoveRows)
 | 
				
			||||||
        self.beginRemoveRows(QModelIndex(), 0, len(self))
 | 
					        self.beginRemoveRows(QModelIndex(), 0, len(self))
 | 
				
			||||||
        self._data.clear()
 | 
					        self._data.clear()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user