check if layout item has widget before calling hide

This commit is contained in:
iLLiCiTiT 2021-11-12 11:20:39 +01:00
parent 5e2e818db2
commit 5532cd3f32
3 changed files with 9 additions and 3 deletions

View file

@ -172,7 +172,9 @@ class LocalApplicationsWidgets(QtWidgets.QWidget):
def _reset_app_widgets(self):
while self.content_layout.count() > 0:
item = self.content_layout.itemAt(0)
item.widget().hide()
widget = item.widget()
if widget is not None:
widget.setVisible(False)
self.content_layout.removeItem(item)
self.widgets_by_group_name.clear()

View file

@ -259,7 +259,9 @@ class SitesWidget(QtWidgets.QWidget):
def _clear_widgets(self):
while self.content_layout.count():
item = self.content_layout.itemAt(0)
item.widget().hide()
widget = item.widget()
if widget is not None:
widget.setVisible(False)
self.content_layout.removeItem(item)
self.input_objects = {}

View file

@ -391,7 +391,9 @@ class SettingsCategoryWidget(QtWidgets.QWidget):
while self.content_layout.count() != 0:
widget = self.content_layout.itemAt(0).widget()
widget.hide()
if widget is not None:
widget.setVisible(False)
self.content_layout.removeWidget(widget)
widget.deleteLater()