diff --git a/src/controllers/dlgprefcontrollers.cpp b/src/controllers/dlgprefcontrollers.cpp index 624881a0926..ef4446de3d8 100644 --- a/src/controllers/dlgprefcontrollers.cpp +++ b/src/controllers/dlgprefcontrollers.cpp @@ -130,9 +130,10 @@ void DlgPrefControllers::rescanControllers() { } void DlgPrefControllers::destroyControllerWidgets() { - for (auto* pController : m_pControllerManager->getControllerList(false, true)) { - pController->disconnect(SIGNAL(&Controller::openChanged)); + for (auto conn : m_controllerConnections) { + disconnect(conn); } + m_controllerConnections.clear(); while (!m_controllerPages.isEmpty()) { DlgPrefController* pControllerDlg = m_controllerPages.takeLast(); m_pDlgPreferences->removePageWidget(pControllerDlg); @@ -174,11 +175,11 @@ void DlgPrefControllers::setupControllerWidgets() { m_controllerPages.append(pControllerDlg); - connect(pController, + m_controllerConnections.append(connect(pController, &Controller::openChanged, [this, pControllerDlg](bool bOpen) { slotHighlightDevice(pControllerDlg, bOpen); - }); + })); QTreeWidgetItem* pControllerTreeItem = new QTreeWidgetItem( QTreeWidgetItem::Type); diff --git a/src/controllers/dlgprefcontrollers.h b/src/controllers/dlgprefcontrollers.h index 3ebda150c86..5cf1d3800ca 100644 --- a/src/controllers/dlgprefcontrollers.h +++ b/src/controllers/dlgprefcontrollers.h @@ -52,4 +52,5 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle QTreeWidgetItem* m_pControllersRootItem; QList m_controllerPages; QList m_controllerTreeItems; + QList m_controllerConnections; };