Fix material model update and signal recursion

CURA-6904
This commit is contained in:
Lipu Fei 2019-10-21 09:53:12 +02:00
parent cd0dbb3902
commit 5602c71ec7
3 changed files with 29 additions and 15 deletions

View file

@ -9,14 +9,14 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
def __init__(self, parent = None):
super().__init__(parent)
cura.CuraApplication.CuraApplication.getInstance().getPreferences().preferenceChanged.connect(self._onFavoritesChanged)
self._update()
self._onChanged()
## Triggered when any preference changes, but only handles it when the list
# of favourites is changed.
def _onFavoritesChanged(self, preference_key: str) -> None:
if preference_key != "cura/favorite_materials":
return
self._update()
self._onChanged()
def _update(self):
if not self._canUpdate():