Skip to content

Commit

Permalink
Merge pull request #4476 from ywwg/disconnect-controllers
Browse files Browse the repository at this point in the history
Disconnect controller qt connections
  • Loading branch information
Holzhaus authored Nov 5, 2021
2 parents d55011f + eb937bb commit e9da247
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controllers/controllermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ void ControllerManager::slotShutdown() {
}

void ControllerManager::updateControllerList() {
// NOTE: Currently this function is only called on startup. If hotplug is added, changes to the
// controller list must be synchronized with dlgprefcontrollers to avoid dangling connections
// and possible crashes.
auto locker = lockMutex(&m_mutex);
if (m_enumerators.isEmpty()) {
qWarning() << "updateControllerList called but no enumerators have been added!";
Expand Down
9 changes: 9 additions & 0 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ void DlgPrefControllers::rescanControllers() {
}

void DlgPrefControllers::destroyControllerWidgets() {
// NOTE: this assumes that the list of controllers does not change during the lifetime of Mixxx.
// This is currently true, but once we support hotplug, we will need better lifecycle management
// to keep this dialog and the controllermanager consistent.
QList<Controller*> controllerList =
m_pControllerManager->getControllerList(false, true);
for (auto controller : controllerList) {
controller->disconnect(this);
}
while (!m_controllerPages.isEmpty()) {
DlgPrefController* pControllerDlg = m_controllerPages.takeLast();
m_pDlgPreferences->removePageWidget(pControllerDlg);
Expand Down Expand Up @@ -173,6 +181,7 @@ void DlgPrefControllers::setupControllerWidgets() {

connect(pController,
&Controller::openChanged,
this,
[this, pControllerDlg](bool bOpen) {
slotHighlightDevice(pControllerDlg, bOpen);
});
Expand Down

0 comments on commit e9da247

Please sign in to comment.