From b8c8477664c74871ff8f6b96871450211d38f84a Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 19 Dec 2020 16:32:37 +0000 Subject: [PATCH] Fix a close down crash due to destruction ordering Static QString variables are unwise as QApplication translators may get destroyed before them. --- widgets/widegraph.cpp | 37 ++++++++++++++++--------------------- widgets/widegraph.h | 2 ++ 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/widgets/widegraph.cpp b/widgets/widegraph.cpp index a369f6296..fa3f1320e 100644 --- a/widgets/widegraph.cpp +++ b/widgets/widegraph.cpp @@ -13,12 +13,6 @@ #include "SettingsGroup.hpp" #include "moc_widegraph.cpp" -namespace -{ - auto user_defined = QObject::tr ("User Defined"); - float swide[MAX_SCREENSIZE]; -} - WideGraph::WideGraph(QSettings * settings, QWidget *parent) : QDialog(parent), ui(new Ui::WideGraph), @@ -26,7 +20,8 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : m_palettes_path {":/Palettes"}, m_tr0 {0.0}, m_n {0}, - m_bHaveTransmitted {false} + m_bHaveTransmitted {false}, + m_user_defined {tr ("User Defined")} { ui->setupUi(this); @@ -103,8 +98,8 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : if(t==m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); index++; } - ui->paletteComboBox->addItem (user_defined); - if (user_defined == m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); + ui->paletteComboBox->addItem (m_user_defined); + if (m_user_defined == m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); readPalette (); } @@ -147,7 +142,7 @@ void WideGraph::saveSettings() //saveS void WideGraph::drawRed(int ia, int ib) { - ui->widePlot->drawRed(ia,ib,swide); + ui->widePlot->drawRed(ia,ib,m_swide); } void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dataSink2 @@ -181,8 +176,8 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat ss += sp; smax=qMax(smax,sp); } -// swide[j]=nbpp*smax; - swide[j]=nbpp*ss; +// m_swide[j]=nbpp*smax; + m_swide[j]=nbpp*ss; } // Time according to this computer @@ -192,7 +187,7 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat float flagValue=1.0e30; if(m_bHaveTransmitted) flagValue=2.0e30; for(int i=0; iwidePlot->draw(swide,true,false); + ui->widePlot->draw(m_swide,true,false); } } @@ -238,7 +233,7 @@ void WideGraph::keyPressEvent(QKeyEvent *e) //F1 void WideGraph::setRxFreq(int n) //setRxFreq { ui->widePlot->setRxFreq(n); - ui->widePlot->draw(swide,false,false); + ui->widePlot->draw(m_swide,false,false); } int WideGraph::rxFreq() //rxFreq @@ -384,7 +379,7 @@ void WideGraph::readPalette () //readPalette { try { - if (user_defined == m_waterfallPalette) + if (m_user_defined == m_waterfallPalette) { ui->widePlot->setColours (WFPalette {m_userPalette}.interpolate ()); } @@ -437,7 +432,7 @@ void WideGraph::on_adjust_palette_push_button_clicked (bool) //Adjust Palette { if (m_userPalette.design ()) { - m_waterfallPalette = user_defined; + m_waterfallPalette = m_user_defined; ui->paletteComboBox->setCurrentText (m_waterfallPalette); readPalette (); } @@ -479,8 +474,8 @@ void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2 { ui->widePlot->setPlot2dGain(value); if(ui->widePlot->scaleOK ()) { - ui->widePlot->draw(swide,false,false); - if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); + ui->widePlot->draw(m_swide,false,false); + if(m_mode=="QRA64") ui->widePlot->draw(m_swide,false,true); } } @@ -488,8 +483,8 @@ void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2 { ui->widePlot->setPlot2dZero(value); if(ui->widePlot->scaleOK ()) { - ui->widePlot->draw(swide,false,false); - if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); + ui->widePlot->draw(m_swide,false,false); + if(m_mode=="QRA64") ui->widePlot->draw(m_swide,false,true); } } diff --git a/widgets/widegraph.h b/widgets/widegraph.h index f5f70c281..421fc8213 100644 --- a/widgets/widegraph.h +++ b/widgets/widegraph.h @@ -117,6 +117,8 @@ private: QString m_mode; QString m_modeTx; QString m_waterfallPalette; + float m_swide[MAX_SCREENSIZE]; + QString m_user_defined; }; #endif // WIDEGRAPH_H