1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

fixing strict-aliasing rule violations by passing enum types as int references

This commit is contained in:
andheh 2018-03-06 10:04:39 +01:00 committed by James Crook
parent 7a30222f49
commit 87eaaa6f45
7 changed files with 18 additions and 13 deletions

View File

@ -263,7 +263,7 @@ WaveTrack::WaveTrackDisplay WaveTrack::FindDefaultViewMode()
// Prefer the NEW preference key if it is present
WaveTrack::WaveTrackDisplay viewMode;
gPrefs->Read(wxT("/GUI/DefaultViewModeNew"), (int*)&viewMode, -1);
gPrefs->Read(wxT("/GUI/DefaultViewModeNew"), &viewMode, -1);
// Default to the old key only if not, default the value if it's not there either
wxASSERT(WaveTrack::MinDisplay >= 0);

View File

@ -527,7 +527,9 @@ private:
// and will be taken out of the WaveTrack class:
//
enum WaveTrackDisplay {
typedef int WaveTrackDisplay;
enum WaveTrackDisplayValues : int {
// DO NOT REORDER OLD VALUES! Replace obsoletes with placeholders.

View File

@ -192,8 +192,8 @@ bool SetTrackCommand::Apply(const CommandContext & context)
if( wt && bHasDisplayType )
wt->SetDisplay(
(mDisplayType == kWaveform) ?
WaveTrack::WaveTrackDisplay::Waveform
: WaveTrack::WaveTrackDisplay::Spectrum
WaveTrack::WaveTrackDisplayValues::Waveform
: WaveTrack::WaveTrackDisplayValues::Spectrum
);
if( wt && bHasScaleType )
wt->GetIndependentWaveformSettings().scaleType =

View File

@ -53,7 +53,8 @@ public:
// Do not assume that this enumeration will remain the
// same as NumberScaleType in future. That enum may become
// more general purpose.
enum ScaleType {
typedef int ScaleType;
enum ScaleTypeValues : int {
stLinear,
stLogarithmic,
stMel,
@ -131,7 +132,8 @@ public:
bool spectralSelection; // But should this vary per track? -- PRL
#endif
enum Algorithm {
typedef int Algorithm;
enum AlgorithmValues : int {
algSTFT = 0,
algReassignment,
algPitchEAC,

View File

@ -176,7 +176,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
S.StartTwoColumn();
{
S.Id(ID_SCALE).TieChoice(_("S&cale") + wxString(wxT(":")),
*(int*)&mTempSettings.scaleType,
mTempSettings.scaleType,
&mScaleChoices);
mMinFreq =
@ -226,7 +226,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
{
mAlgorithmChoice =
S.Id(ID_ALGORITHM).TieChoice(_("A&lgorithm") + wxString(wxT(":")),
*(int*)&mTempSettings.algorithm,
mTempSettings.algorithm,
&mAlgorithmChoices);
S.Id(ID_WINDOW_SIZE).TieChoice(_("Window &size:"),

View File

@ -92,12 +92,12 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
{
mScaleChoice =
S.Id(ID_SCALE).TieChoice(_("S&cale") + wxString(wxT(":")),
*(int*)&mTempSettings.scaleType,
mTempSettings.scaleType,
&mScaleChoices);
mRangeChoice =
S.Id(ID_RANGE).TieChoice(_("Waveform dB &range") + wxString(wxT(":")),
*(int*)&mTempSettings.dBRange,
mTempSettings.dBRange,
&mRangeChoices);
S.SetSizeHints(mRangeChoices);
}

View File

@ -50,7 +50,8 @@ public:
void NextLowerDBRange();
void NextHigherDBRange();
enum ScaleType {
typedef int ScaleType;
enum ScaleTypeValues : int {
stLinear,
stLogarithmic,