Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop browse thread before deleting the library #11593

Merged
merged 3 commits into from
Jun 5, 2023
Merged

Conversation

daschuer
Copy link
Member

This will fix #11589

@ronso0
Copy link
Member

ronso0 commented May 26, 2023

IIUC this isn't stopping the BrowseThread, it just resets the BrowseThreadPointer to prevent further calls from and callbacks to the BrowseFeature/BrowseTableModel.

Is real stopping required? (didn't understand the actual bug tbh)
If yes, that could be achieved via m_bStopThread like in the BrowseThread destructor.
If no, the new method should probably be renamed.

@daschuer
Copy link
Member Author

Yes, the code is not obvious. I have added a comment.

The issue was that if the browse thread is using the library and when you quit Mixxx in the mean time from the main thread. It is using dangling pointers and crashes Mixxx.
The fix is to stop these threads and wait until they are really terminated and then continue destructing the library.
This is done here implicit by releasing all references to the browse thread (The last reset() calls immediately the destructor).

Currently the recording feature and the browse feature are using this thread. The recording feature is destructed earlier because it is places in the widget tree of the skin. This asymmetry is not obvious and bites me during development, but a fix would involve a bigger refactoring. Probably required when moving to QML, but not in the stable 2.3 branch.

Copy link
Member

@ronso0 ronso0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the QSharedPointer explanation.

@ronso0
Copy link
Member

ronso0 commented May 30, 2023

@mixxxdj/developers Anyone else minds taking a look?

@@ -471,3 +473,10 @@ QAbstractItemDelegate* BrowseTableModel::delegateForColumn(const int i, QObject*
}
return nullptr;
}

void BrowseTableModel::stopBrowseThread() {
// The shared browse thread is actually stopped in the desctuctor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

@@ -471,3 +473,10 @@ QAbstractItemDelegate* BrowseTableModel::delegateForColumn(const int i, QObject*
}
return nullptr;
}

void BrowseTableModel::stopBrowseThread() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this function is inappropriate as the comment tells. It doesn't stop the browse thread, it just drops one of multiple references.

-> resetBrowseThread() or releaseBrowseThread()?

@daschuer
Copy link
Member Author

daschuer commented Jun 1, 2023

Done.

@ronso0
Copy link
Member

ronso0 commented Jun 5, 2023

Thank you!

@ronso0 ronso0 merged commit 9333cfb into mixxxdj:2.3 Jun 5, 2023
@ronso0 ronso0 added the bug label Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants