Skip to content

Commit

Permalink
controller disconnect: store an explicit list of connections
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Oct 23, 2021
1 parent 2c800c3 commit 7b595c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/controllers/dlgprefcontrollers.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle
QTreeWidgetItem* m_pControllersRootItem;
QList<DlgPrefController*> m_controllerPages;
QList<QTreeWidgetItem*> m_controllerTreeItems;
QList<QMetaObject::Connection> m_controllerConnections;
};

0 comments on commit 7b595c0

Please sign in to comment.