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

Fix clazy issues on main #12028

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/preferences/dialog/dlgprefsound.cpp
Original file line number Diff line number Diff line change
@@ -68,7 +68,8 @@ DlgPrefSound::DlgPrefSound(QWidget* pParent,
&DlgPrefSound::apiChanged);

sampleRateComboBox->clear();
for (const auto& sampleRate : m_pSoundManager->getSampleRates()) {
const auto sampleRates = m_pSoundManager->getSampleRates();
for (const auto& sampleRate : sampleRates) {
Comment on lines +71 to +72
Copy link
Member

Choose a reason for hiding this comment

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

what warning does this fix? just out of curiosity because I don't see why one would be preferred over the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, I would've preferred std::as_const(m_pSoundManager->getSampleRates()) instead though, without the extra variable. Otherwise it would make me think that sampleRates is used outside the loop as well. Any reason you decided against that?

Copy link
Member Author

@Holzhaus Holzhaus Sep 26, 2023

Choose a reason for hiding this comment

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

It's not possible:

src/preferences/dialog/dlgprefsound.cpp: In constructor ‘DlgPrefSound::DlgPrefSound(QWidget*, std::shared_ptr<SoundManager>, UserSettingsPointer)’:
src/preferences/dialog/dlgprefsound.cpp:71:48: error: use of deleted function ‘void std::as_const(const _Tp&&) [with _Tp = QList<mixxx::audio::SampleRate>]’
   71 |     for (const auto& sampleRate : std::as_const(m_pSoundManager->getSampleRates())) {
      |                                   ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt/QtCore/qglobal.h:47,
                 from /usr/include/qt/QtCore/qalgorithms.h:43,
                 from /usr/include/qt/QtCore/qdebug.h:44,
                 from /usr/include/qt/QtCore/QDebug:1,
                 from /home/jan/Projects/mixxx/src/audio/frame.h:3,
                 from /home/jan/Projects/mixxx/build/CMakeFiles/mixxx-lib.dir/cmake_pch.hxx:5,
                 from <command-line>:
/usr/include/c++/13.2.1/utility:112:10: note: declared here
  112 |     void as_const(const _Tp&&) = delete;
      |          ^~~~~~~~
      ```

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, of course. thats probably why C++ now supports an init statement...
that has been shot down previously in code review (without good reason IMO) so I'm not suggesting to use it.

    for (const auto sampleRates = m_pSoundManager->getSampleRates(); const auto& sampleRate : sampleRates) {

if (sampleRate.isValid()) {
// no ridiculous sample rate values. prohibiting zero means
// avoiding a potential div-by-0 error in ::updateLatencies