From 3a9d169d463d389af302e592169cf1e5b7bb6760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sun, 23 Oct 2022 20:34:20 +0200 Subject: [PATCH] Fixing variable initializations part 1 --- .../Calibration/amplitudecaldialog.cpp | 2 + .../LibreVNA-GUI/Calibration/calibration.cpp | 26 ++++---- .../LibreVNA-GUI/CustomWidgets/csvimport.h | 1 - .../LibreVNA-GUI/CustomWidgets/tilewidget.cpp | 1 + .../Device/compounddeviceeditdialog.cpp | 5 +- .../Device/compounddeviceeditdialog.h | 1 - .../Device/firmwareupdatedialog.cpp | 3 +- .../LibreVNA-GUI/Device/virtualdevice.cpp | 1 - .../Generator/signalgenwidget.cpp | 1 + .../SpectrumAnalyzer/spectrumanalyzer.cpp | 10 +++- .../LibreVNA-GUI/Tools/parameters.h | 60 +------------------ .../LibreVNA-GUI/Traces/Math/dft.cpp | 4 +- .../LibreVNA-GUI/Traces/Math/tracemath.h | 2 +- .../LibreVNA-GUI/Traces/eyediagramplot.cpp | 4 +- .../LibreVNA-GUI/Traces/traceplot.cpp | 8 +-- .../LibreVNA-GUI/modehandler.cpp | 4 +- .../PC_Application/LibreVNA-GUI/modehandler.h | 2 +- Software/PC_Application/LibreVNA-GUI/unit.h | 2 +- 18 files changed, 47 insertions(+), 90 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp index 462aee8..4714bd7 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/amplitudecaldialog.cpp @@ -24,6 +24,7 @@ AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidge dev(dev), modeHandler(handler), model(this), + edited(false), mode(CalibrationMode::BothPorts) { activeMode = modeHandler->getActiveMode(); @@ -350,6 +351,7 @@ void AmplitudeCalDialog::AddPointDialog() void AmplitudeCalDialog::AutomaticMeasurementDialog() { + automatic = {}; automatic.isSourceCal = pointType() == Protocol::PacketType::SourceCalPoint; const QString ownCal = automatic.isSourceCal ? "Source" : "Receiver"; const QString otherCal = automatic.isSourceCal ? "Receiver" : "Source"; diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp index 484b62b..78dd9e0 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp @@ -684,16 +684,16 @@ Calibration::Point Calibration::createInitializedPoint(double f) { Point point; point.frequency = f; // resize vectors - point.D.resize(caltype.usedPorts.size()); - point.R.resize(caltype.usedPorts.size()); - point.S.resize(caltype.usedPorts.size()); + point.D.resize(caltype.usedPorts.size(), 0.0); + point.R.resize(caltype.usedPorts.size(), 0.0); + point.S.resize(caltype.usedPorts.size(), 0.0); point.L.resize(caltype.usedPorts.size()); point.T.resize(caltype.usedPorts.size()); point.I.resize(caltype.usedPorts.size()); - fill(point.L.begin(), point.L.end(), vector>(caltype.usedPorts.size())); - fill(point.T.begin(), point.T.end(), vector>(caltype.usedPorts.size())); - fill(point.I.begin(), point.I.end(), vector>(caltype.usedPorts.size())); + fill(point.L.begin(), point.L.end(), vector>(caltype.usedPorts.size(), 0.0)); + fill(point.T.begin(), point.T.end(), vector>(caltype.usedPorts.size(), 0.0)); + fill(point.I.begin(), point.I.end(), vector>(caltype.usedPorts.size(), 0.0)); return point; } @@ -802,7 +802,7 @@ Calibration::Point Calibration::computeThroughNormalization(double f) // grab measurement and calkit through definitions auto throughForward = static_cast(findMeasurement(CalibrationMeasurement::Base::Type::Through, p1, p2)); auto throughReverse = static_cast(findMeasurement(CalibrationMeasurement::Base::Type::Through, p2, p1)); - complex S21; + complex S21 = 0.0; Sparam Sideal; if(throughForward) { S21 = throughForward->getMeasured(f).m21; @@ -1761,35 +1761,35 @@ Calibration::Point Calibration::Point::interpolate(const Calibration::Point &to, { Point ret; ret.frequency = frequency * (1.0-alpha) + to.frequency * alpha; - ret.D.resize(D.size()); + ret.D.resize(D.size(), 0.0); for(unsigned int i=0;isetupUi(this); diff --git a/Software/PC_Application/LibreVNA-GUI/Device/compounddeviceeditdialog.h b/Software/PC_Application/LibreVNA-GUI/Device/compounddeviceeditdialog.h index d775c60..92daa1f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/compounddeviceeditdialog.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/compounddeviceeditdialog.h @@ -28,7 +28,6 @@ private: static constexpr int frameSize = 350; QComboBox *serial; QComboBox *port1, *port2; - QLabel *image; unsigned int position; CompoundDevice *dev; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp b/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp index 1ecbf4c..eb00a45 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/firmwareupdatedialog.cpp @@ -11,7 +11,8 @@ FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) : dev(dev), file(), timer(), - state(State::Idle) + state(State::Idle), + transferredBytes(0) { ui->setupUi(this); ui->bFile->setIcon(this->style()->standardPixmap(QStyle::SP_FileDialogStart)); diff --git a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp index 169cab2..f2e6963 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp @@ -105,7 +105,6 @@ VirtualDevice::VirtualDevice(QString serial) info{}, status{} { - cdev = nullptr; cdev = nullptr; zerospan = false; diff --git a/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp b/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp index 68b4543..bc5ff64 100644 --- a/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp @@ -5,6 +5,7 @@ SignalgeneratorWidget::SignalgeneratorWidget(AppWindow *window, QWidget *parent) : QWidget(parent), ui(new Ui::SignalgeneratorWidget), + m_timerId(0), window(window) { ui->setupUi(this); diff --git a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp index 6b93573..3694739 100644 --- a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -46,8 +46,10 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name) : Mode(window, name, "SA"), - central(new TileWidget(traceModel, window)) + central(new TileWidget(traceModel, window)), + firstPointTime(0) { + changingSettings = false; averages = 1; singleSweep = false; settings = {}; @@ -55,6 +57,12 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name) normalize.measuring = false; normalize.points = 0; normalize.dialog.reset(); + normalize.f_start = 0; + normalize.f_stop = 0; + normalize.points = 0; + normalize.Level = nullptr; + normalize.measure = nullptr; + normalize.enable = nullptr; traceModel.setSource(TraceModel::DataSource::SA); diff --git a/Software/PC_Application/LibreVNA-GUI/Tools/parameters.h b/Software/PC_Application/LibreVNA-GUI/Tools/parameters.h index fa2c1c6..eea7ac5 100644 --- a/Software/PC_Application/LibreVNA-GUI/Tools/parameters.h +++ b/Software/PC_Application/LibreVNA-GUI/Tools/parameters.h @@ -11,7 +11,7 @@ class Parameters : public Savable { public: Parameters(Type m11, Type m12, Type m21, Type m22) : m11(m11), m12(m12), m21(m21), m22(m22){} - Parameters(){} + Parameters() : m11(0.0),m12(0.0),m21(0.0),m22(0.0){} Type m11, m12, m21, m22; @@ -131,62 +131,4 @@ public: } }; -//template -//class Tparam { -//public: -// Tparam(){}; -// Tparam(T t11, T t12, T t21, T t22) -// : t11(t11), t12(t12), t21(t21), t22(t22){}; -// void fromSparam(T S11, T S21, T S12, T S22) { -// t11 = -(S11*S22 - S12*S21) / S21; -// t12 = S11 / S21; -// t21 = -S22 / S21; -// t22 = 1.0 / S21; -// } -// void toSparam(T &S11, T &S21, T &S12, T &S22) { -// S11 = t12 / t22; -// S21 = T(1) / t22; -// S12 = (t11*t22 - t12*t21) / t22; -// S22 = -t21 / t22; -// } -// Tparam inverse() { -// Tparam i; -// T det = t11*t22 - t12*t21; -// i.t11 = t22 / det; -// i.t12 = -t12 / det; -// i.t21 = -t21 / det; -// i.t22 = t11 / det; -// return i; -// } -// Tparam root() { -// // calculate root of 2x2 matrix, according to https://en.wikipedia.org/wiki/Square_root_of_a_2_by_2_matrix (choose positive roots) -// auto tau = t11 + t22; -// auto sigma = t11*t22 - t12*t21; -// auto s = sqrt(sigma); -// auto t = sqrt(tau + 2.0*s); -// Tparam r = *this; -// r.t11 += s; -// r.t22 += s; -// r = r * (1.0/t); -// return r; -// } -// Tparam operator*(const Tparam &r) { -// Tparam p; -// p.t11 = t11*r.t11 + t12*r.t21; -// p.t12 = t11*r.t12 + t12*r.t22; -// p.t21 = t21*r.t11 + t22*r.t21; -// p.t22 = t21*r.t12 + t22*r.t22; -// return p; -// } -// Tparam operator*(const T &r) { -// Tparam p; -// p.t11 = t11 * r; -// p.t12 = t12 * r; -// p.t21 = t21 * r; -// p.t22 = t22 * r; -// return p; -// } -// T t11, t12, t21, t22; -//}; - #endif // TPARAM_H diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/Math/dft.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/Math/dft.cpp index 2fc970f..576aa84 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/Math/dft.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/Math/dft.cpp @@ -212,10 +212,10 @@ void Math::DFTThread::run() dft.data.clear(); int DCbin = timeDomain.size() / 2, startBin = 0; if(DC > 0) { - dft.data.resize(timeDomain.size()); + dft.data.resize(timeDomain.size(), TraceMath::Data()); } else { startBin = (timeDomain.size()+1) / 2; - dft.data.resize(timeDomain.size()/2); + dft.data.resize(timeDomain.size()/2, TraceMath::Data()); } // reverse effect of frequency domain window function from TDR (if available) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h b/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h index 649de24..ad6c894 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h @@ -53,7 +53,7 @@ public: class Data { public: - Data() : x(){} + Data() : x(0){} double x; std::complex y; }; diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp index 24d35bf..942a430 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp @@ -825,13 +825,13 @@ void EyeDiagramPlot::updateThread(unsigned int xSamples) setStatus("Generating PRBS sequence..."); - auto prbs = new PRBS(patternbits); + auto prbs = PRBS(patternbits); auto getNextLevel = [&]() -> unsigned int { unsigned int level = 0; for(unsigned int i=0;inext()) { + if(prbs.next()) { level |= 0x01; } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index f40ecf6..da2eede 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -289,25 +289,25 @@ void TracePlot::finishContextMenu() contextmenu->addSeparator(); if(parentTile) { auto add = new QMenu("Add tile...", contextmenu); - auto left = new QAction("to the left"); + auto left = new QAction("to the left", contextmenu); connect(left, &QAction::triggered, [=](){ // split, keep current graph on the right parentTile->splitHorizontally(true); }); add->addAction(left); - auto right = new QAction("to the right"); + auto right = new QAction("to the right", contextmenu); connect(right, &QAction::triggered, [=](){ // split, keep current graph on the left parentTile->splitHorizontally(false); }); add->addAction(right); - auto above = new QAction("above"); + auto above = new QAction("above", contextmenu); connect(above, &QAction::triggered, [=](){ // split, keep current graph on the bottom parentTile->splitVertically(true); }); add->addAction(above); - auto below = new QAction("below"); + auto below = new QAction("below", contextmenu); connect(below, &QAction::triggered, [=](){ // split, keep current graph on the top parentTile->splitVertically(false); diff --git a/Software/PC_Application/LibreVNA-GUI/modehandler.cpp b/Software/PC_Application/LibreVNA-GUI/modehandler.cpp index b42a79e..e44d8be 100644 --- a/Software/PC_Application/LibreVNA-GUI/modehandler.cpp +++ b/Software/PC_Application/LibreVNA-GUI/modehandler.cpp @@ -8,7 +8,9 @@ ModeHandler::ModeHandler(AppWindow *aw): QObject(), - aw(aw) + currentModeIndex(0), + aw(aw), + activeMode(nullptr) {} void ModeHandler::shutdown() diff --git a/Software/PC_Application/LibreVNA-GUI/modehandler.h b/Software/PC_Application/LibreVNA-GUI/modehandler.h index e34e662..ea0d1c7 100644 --- a/Software/PC_Application/LibreVNA-GUI/modehandler.h +++ b/Software/PC_Application/LibreVNA-GUI/modehandler.h @@ -49,7 +49,7 @@ private: int createMode(Mode *mode); Mode *createNew(AppWindow *window, QString name, Mode::Type t); AppWindow *aw; - Mode *activeMode = nullptr; + Mode *activeMode; private slots: void setStatusBarMessageChanged(const QString &msg); diff --git a/Software/PC_Application/LibreVNA-GUI/unit.h b/Software/PC_Application/LibreVNA-GUI/unit.h index 6440dc1..647e908 100644 --- a/Software/PC_Application/LibreVNA-GUI/unit.h +++ b/Software/PC_Application/LibreVNA-GUI/unit.h @@ -10,6 +10,6 @@ namespace Unit // prefixed need to be in ascending order (e.g. "m kMG" is okay, whjle "MkG" does not work) QString ToString(double value, QString unit = QString(), QString prefixes = " ", int precision = 6); double SIPrefixToFactor(char prefix); -}; +} #endif // UNIT_H