Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dlgprefwaveform): Fix
-Wdangling-reference
on GCC 14.1.1
Fixes the following warning: src/preferences/dialog/dlgprefwaveform.cpp: In member function ‘void DlgPrefWaveform::updateWaveformAcceleration(WaveformWidgetType::Type, WaveformWidgetBackend)’: src/preferences/dialog/dlgprefwaveform.cpp:462:21: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 462 | const auto& handle = factory->getAvailableTypes()[handleIdx]; | ^~~~~~ src/preferences/dialog/dlgprefwaveform.cpp:462:68: note: the temporary was destroyed at the end of the full expression ‘WaveformWidgetFactory::getAvailableTypes() const().QList<WaveformWidgetAbstractHandle>::operator[](((qsizetype)handleIdx))’ 462 | const auto& handle = factory->getAvailableTypes()[handleIdx]; | ^ cc1plus: all warnings being treated as errors I made `getAvailableTypes()` return a const reference to show that the underlying `QVector` does not get dropped. Alternatively, we'd have to save the return value in a temporary local variable to fix the warning.
- Loading branch information