mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Fix cppcoreguidelines-init-variables warnings
This commit is contained in:
@@ -45,6 +45,7 @@ Checks: >
|
||||
readability-use-std-min-max,
|
||||
readability-use-anyofallof,
|
||||
readability-redundant-member-init,
|
||||
cppcoreguidelines-init-variables,
|
||||
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.ClassCase
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace swift::core::afv::audio
|
||||
m_maxSampleInput = qMax(qAbs(sampleInput), m_maxSampleInput);
|
||||
}
|
||||
|
||||
int length;
|
||||
int length {};
|
||||
const QByteArray encodedBuffer = m_encoder.encode(samples, samples.size(), &length);
|
||||
m_opusBytesEncoded += length;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace swift::core
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextApplicationProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
|
||||
: IContextApplication(mode, runtime), m_dBusInterface(nullptr)
|
||||
: IContextApplication(mode, runtime)
|
||||
{}
|
||||
|
||||
//! DBus version constructor
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace swift::core::context
|
||||
{
|
||||
CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder;
|
||||
}
|
||||
bool changed;
|
||||
bool changed {};
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
changed = m_ownAircraft.hasChangedCockpitData(com1, com2, transponder);
|
||||
@@ -301,7 +301,7 @@ namespace swift::core::context
|
||||
{
|
||||
CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO << transponderMode;
|
||||
}
|
||||
bool changed;
|
||||
bool changed {};
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
changed = m_ownAircraft.setTransponderMode(transponderMode);
|
||||
|
||||
@@ -425,7 +425,7 @@ namespace swift::core::db
|
||||
const int contentIndex = content.indexOf(':', cl);
|
||||
if (contentIndex < cl) break; // should not happen, malformed
|
||||
const QString ls = content.mid(cl, contentIndex - cl); // content length
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const qint32 size = ls.toInt(&ok);
|
||||
if (!ok) break; // malformed size
|
||||
if (size < 1) break;
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace swift::core::db
|
||||
CAircraftModelList modelsPublished;
|
||||
CAircraftModelList modelsSkipped;
|
||||
CStatusMessageList msgs;
|
||||
bool directWrite;
|
||||
bool directWrite {};
|
||||
const bool sendingSuccessful =
|
||||
parseSwiftPublishResponse(responseData, modelsPublished, modelsSkipped, msgs, directWrite);
|
||||
const int c = CDatabaseUtils::fillInMissingAircraftAndLiveryEntities(modelsPublished);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace swift::core::fsd
|
||||
|
||||
QStringList InterimPilotDataUpdate::toTokens() const
|
||||
{
|
||||
std::uint32_t pbh;
|
||||
std::uint32_t pbh {};
|
||||
packPBH(m_pitch, m_bank, m_heading, m_onGround, pbh);
|
||||
|
||||
auto tokens = QStringList {};
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace swift::core::fsd
|
||||
|
||||
QStringList PilotDataUpdate::toTokens() const
|
||||
{
|
||||
std::uint32_t pbh;
|
||||
std::uint32_t pbh {};
|
||||
packPBH(m_pitch, m_bank, m_heading, m_onGround, pbh);
|
||||
|
||||
QStringList tokens;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace swift::core::fsd
|
||||
|
||||
QStringList VisualPilotDataPeriodic::toTokens() const
|
||||
{
|
||||
std::uint32_t pbh;
|
||||
std::uint32_t pbh {};
|
||||
packPBH(m_pitch, m_bank, m_heading, false /*! \todo check if needed? */, pbh);
|
||||
|
||||
QStringList tokens;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace swift::core::fsd
|
||||
|
||||
QStringList VisualPilotDataStopped::toTokens() const
|
||||
{
|
||||
std::uint32_t pbh;
|
||||
std::uint32_t pbh {};
|
||||
packPBH(m_pitch, m_bank, m_heading, false /*! \todo check if needed? */, pbh);
|
||||
|
||||
QStringList tokens;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace swift::core::fsd
|
||||
|
||||
QStringList VisualPilotDataUpdate::toTokens() const
|
||||
{
|
||||
std::uint32_t pbh;
|
||||
std::uint32_t pbh {};
|
||||
packPBH(m_pitch, m_bank, m_heading, false /*! \todo check if needed? */, pbh);
|
||||
|
||||
QStringList tokens;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace swift::core
|
||||
|
||||
private:
|
||||
std::atomic<bool> m_setupAvailable { false }; //!< setup available?
|
||||
data::CGlobalSetup m_setup {}; //!< data setup
|
||||
data::CGlobalSetup m_setup; //!< data setup
|
||||
|
||||
//! Read by local file
|
||||
swift::misc::CStatusMessageList readLocalBootstrapFile();
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace swift::core
|
||||
if (part2.startsWith("max"))
|
||||
{
|
||||
if (!parser.hasPart(3)) { return false; }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int max = parser.part(3).toInt(&ok);
|
||||
if (!ok) { return false; }
|
||||
m_interpolationLogger.setMaxSituations(max);
|
||||
|
||||
@@ -450,7 +450,8 @@ namespace swift::gui::components
|
||||
m_splitterSizes = ui->sp_AtcSplitter->sizes();
|
||||
if (m_splitterSizes.size() > 1)
|
||||
{
|
||||
int min, max;
|
||||
int min {};
|
||||
int max {};
|
||||
ui->sp_AtcSplitter->getRange(1, &min, &max);
|
||||
QList<int> newSizes;
|
||||
newSizes.push_back(qMax(0, m_splitterSizes.first() + m_splitterSizes.last() - min));
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace swift::gui::components
|
||||
QWidget *w = qobject_cast<QWidget *>(QObject::sender());
|
||||
if (!w) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextOwnAircraft()) { return; }
|
||||
CTransponder::TransponderMode mode;
|
||||
CTransponder::TransponderMode mode {};
|
||||
if (m_ledStandby.data() == w) { mode = CTransponder::StateStandby; }
|
||||
else if (m_ledIdent.data() == w) { mode = CTransponder::StateIdent; }
|
||||
else if (m_ledModes.data() == w) { mode = CTransponder::ModeC; }
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace swift::gui::components
|
||||
int maxObjectsStashed = -1;
|
||||
if (!ui->le_MaxModelsStashed->text().isEmpty())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
ui->le_MaxModelsStashed->text().toInt(&ok);
|
||||
if (!ok) { maxObjectsStashed = 100; }
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ namespace swift::gui::components
|
||||
int currentSize = ui->sp_MappingComponent->sizes().last(); // current size
|
||||
if (h2 <= currentSize) { return; }
|
||||
|
||||
int h1;
|
||||
int h1 {};
|
||||
if (h * 0.90 > h2)
|
||||
{
|
||||
// enough space to display as whole
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace swift::gui::components
|
||||
void CHotkeyDialog::clearAdvancedFrame()
|
||||
{
|
||||
QLayout *layout = ui->qf_Advanced->layout();
|
||||
QLayoutItem *child;
|
||||
QLayoutItem *child {};
|
||||
|
||||
while ((child = layout->takeAt(0)) != nullptr)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace swift::gui::components
|
||||
void CRawFsdMessagesComponent::enableDisableRawFsdMessages()
|
||||
{
|
||||
//! \fixme KB 2019-03 hardcoded style sheet
|
||||
bool enable;
|
||||
bool enable {};
|
||||
if (ui->pb_EnableDisable->text() == "Enable")
|
||||
{
|
||||
enable = true;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace swift::gui::components
|
||||
const QStringList matches = match.capturedTexts();
|
||||
if (matches.size() != 2) { return false; }
|
||||
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int ptSize = matches.last().toInt(&ok);
|
||||
if (!ok) { return false; }
|
||||
if (increase)
|
||||
|
||||
@@ -484,7 +484,10 @@ namespace swift::gui::components
|
||||
auto *layout = new QVBoxLayout(newTabWidget);
|
||||
auto *textEdit = new CTextMessageTextEdit(newTabWidget);
|
||||
textEdit->setObjectName("tep_" + tabName);
|
||||
int marginLeft, marginRight, marginTop, marginBottom;
|
||||
int marginLeft {};
|
||||
int marginRight {};
|
||||
int marginTop {};
|
||||
int marginBottom {};
|
||||
ui->tb_TextMessagesAll->layout()->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom);
|
||||
newTabWidget->layout()->setContentsMargins(marginLeft, marginTop, marginRight, 2);
|
||||
layout->addWidget(textEdit);
|
||||
@@ -773,7 +776,7 @@ namespace swift::gui::components
|
||||
else
|
||||
{
|
||||
// not a standard channel
|
||||
bool isNumber;
|
||||
bool isNumber {};
|
||||
const QString selectedTabText = firstPartOfTabText(ui->tw_TextMessages->tabText(index).trimmed());
|
||||
const double frequency = selectedTabText.toDouble(&isNumber);
|
||||
if (isNumber)
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace swift::gui::editors
|
||||
const QString family(ui->le_Family->text().trimmed().toUpper());
|
||||
const QString wtc(ui->cb_Wtc->currentText().left(1));
|
||||
const QString combined(ui->combined_TypeSelector->getCombinedType());
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int rank = ui->cb_Rank->currentText().toInt(&ok);
|
||||
if (!ok) { rank = 10; }
|
||||
bool legacy = ui->cb_Legacy->isChecked();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace swift::gui::editors
|
||||
const QString id = ui->le_Id->text();
|
||||
if (sGui && !sGui->isShuttingDown() && sGui->hasWebDataServices())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int dbKey = id.toInt(&ok);
|
||||
if (ok) { code = sGui->getWebDataServices()->getAirlineIcaoCodeForDbKey(dbKey); }
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace swift::gui::editors
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->hasWebDataServices()) { return; }
|
||||
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int id = ui->le_Id->text().toInt(&ok);
|
||||
const CAirlineIcaoCode icao = sGui->getWebDataServices()->getAirlineIcaoCodeForDbKey(id);
|
||||
if (ok && !icao.isLoadedFromDb())
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace swift::gui::editors
|
||||
|
||||
void CCoordinateForm::latCombinedEntered()
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int deg = ui->le_LatDeg->text().trimmed().toInt(&ok);
|
||||
if (!ok) return;
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace swift::gui::editors
|
||||
|
||||
void CCoordinateForm::lngCombinedEntered()
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int deg = ui->le_LngDeg->text().trimmed().toInt(&ok);
|
||||
if (!ok) return;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace swift::gui::editors
|
||||
const QString id = ui->le_Id->text();
|
||||
if (!id.isEmpty() && sGui && !sGui->isShuttingDown() && sGui->hasWebDataServices())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int dbKey = id.toInt(&ok);
|
||||
if (ok) { livery = sGui->getWebDataServices()->getLiveryForDbKey(dbKey); }
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace swift::gui::editors
|
||||
// without unit we assume ft
|
||||
if (isDigitsOnlyString(v))
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const double cgv = v.toDouble(&ok);
|
||||
if (!ok) { return CLength::null(); }
|
||||
return { cgv, CLengthUnit::ft() };
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace swift::gui::editors
|
||||
double CPbhsForm::getBankAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Bank->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
@@ -67,7 +67,7 @@ namespace swift::gui::editors
|
||||
double CPbhsForm::getPitchAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Pitch->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
@@ -87,7 +87,7 @@ namespace swift::gui::editors
|
||||
double CPbhsForm::getHeadingAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Heading->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace swift::gui::editors
|
||||
double CSituationForm::getBankAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Bank->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
@@ -94,7 +94,7 @@ namespace swift::gui::editors
|
||||
double CSituationForm::getPitchAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Pitch->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
@@ -105,7 +105,7 @@ namespace swift::gui::editors
|
||||
double CSituationForm::getHeadingAngleDegrees() const
|
||||
{
|
||||
const QString v(ui->le_Heading->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 0.0; }
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
@@ -114,7 +114,7 @@ namespace swift::gui::editors
|
||||
double CSituationForm::getBarometricPressureMslMillibar() const
|
||||
{
|
||||
const QString v(ui->le_Pressure->text().replace(',', '.'));
|
||||
bool ok;
|
||||
bool ok {};
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = CAltitude::standardISASeaLevelPressure().value(CPressureUnit::mbar()); }
|
||||
return vd;
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace swift::gui::models
|
||||
}
|
||||
|
||||
CListModelBaseNonTemplate::CListModelBaseNonTemplate(const QString &translationContext, QObject *parent)
|
||||
: QStandardItemModel(parent), m_columns(translationContext), m_sortColumn(-1), m_sortOrder(Qt::AscendingOrder)
|
||||
: QStandardItemModel(parent), m_columns(translationContext)
|
||||
{
|
||||
// non unique default name, set translation context as default
|
||||
this->setObjectName(translationContext);
|
||||
|
||||
@@ -180,9 +180,9 @@ namespace swift::gui::models
|
||||
CListModelBaseNonTemplate(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
CColumns m_columns; //!< columns metadata
|
||||
int m_sortColumn; //!< currently sorted column
|
||||
int m_sortColumn { -1 }; //!< currently sorted column
|
||||
bool m_modelDestroyed = false; //!< \todo rudimentary workaround for T579, can be removed
|
||||
Qt::SortOrder m_sortOrder; //!< sort order (asc/desc)
|
||||
Qt::SortOrder m_sortOrder { Qt::AscendingOrder }; //!< sort order (asc/desc)
|
||||
Qt::DropActions m_dropActions = Qt::IgnoreAction; //!< drop actions
|
||||
swift::misc::CPropertyIndexList
|
||||
m_sortTieBreakers; //!< how column values are sorted if equal, if no value is given this is random
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace swift::misc::aviation
|
||||
if (m_combinedType.length() < 2) { return -1; }
|
||||
const QString c(m_combinedType.mid(1, 1));
|
||||
if (c == "-") { return -1; }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int ec = c.toInt(&ok);
|
||||
if (ok && ec >= 0 && ec < 10) { return ec; }
|
||||
return -1;
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace swift::misc::aviation
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
bool ok {};
|
||||
if (v.startsWith("F", Qt::CaseInsensitive))
|
||||
{
|
||||
this->setUnit(CLengthUnit::ft());
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace swift::misc::aviation
|
||||
int CCallsign::getFlightNumberInt() const
|
||||
{
|
||||
if (this->isAtcCallsign()) { return -1; }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int fn = this->getFlightNumber().toInt(&ok);
|
||||
return ok ? fn : -1;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace swift::misc::aviation
|
||||
//! Incremental update or add object
|
||||
int incrementalUpdateOrAdd(const OBJ &objectBeforeChanges, const CPropertyIndexVariantMap &changedValues)
|
||||
{
|
||||
int c;
|
||||
int c {};
|
||||
const CCallsign cs = objectBeforeChanges.getCallsign();
|
||||
if (this->containsCallsign(cs))
|
||||
{
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace swift::misc::aviation
|
||||
comFreq.parseFromString(input, sep);
|
||||
if (comFreq.isNull())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const double f = CPqString::parseNumber(input, ok, sep);
|
||||
if (ok) { comFreq = CFrequency(f, f > 999 ? CFrequencyUnit::kHz() : CFrequencyUnit::MHz()); }
|
||||
else { comFreq = CFrequency::null(); }
|
||||
|
||||
@@ -444,7 +444,7 @@ namespace swift::misc::aviation
|
||||
const QDomNodeList generalList = doc.elementsByTagName("general");
|
||||
if (!generalList.isEmpty())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const QDomNode general = generalList.at(0);
|
||||
QString route = general.firstChildElement("route").text();
|
||||
fp.setRoute(route.remove("DCT").simplified().trimmed());
|
||||
@@ -470,7 +470,7 @@ namespace swift::misc::aviation
|
||||
const QDomNodeList timeList = doc.elementsByTagName("times");
|
||||
if (!timeList.isEmpty())
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const QDomNode times = timeList.at(0);
|
||||
const QString enroute = times.firstChildElement("est_time_enroute").text();
|
||||
const int enrouteSecs = enroute.toInt(&ok);
|
||||
|
||||
@@ -54,7 +54,10 @@ namespace swift::misc::aviation
|
||||
bool CSelcal::isValidCode(const QString &code)
|
||||
{
|
||||
if (code.length() != 4) return false;
|
||||
int p1, p2, p3, p4;
|
||||
int p1 {};
|
||||
int p2 {};
|
||||
int p3 {};
|
||||
int p4 {};
|
||||
QString codeUpper = code.toUpper();
|
||||
if ((p1 = CSelcal::validCharacters().indexOf(codeUpper.at(0))) < 0) return false;
|
||||
if ((p2 = CSelcal::validCharacters().indexOf(codeUpper.at(1))) < 0) return false;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace swift::misc::aviation
|
||||
{
|
||||
if (CTransponder::isValidTransponderCode(transponderCode))
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
this->setTransponderCode(transponderCode.toInt(&ok));
|
||||
}
|
||||
else { Q_ASSERT_X(false, "CTransponder::setTransponderCode", "illegal transponder value"); }
|
||||
@@ -129,7 +129,7 @@ namespace swift::misc::aviation
|
||||
bool CTransponder::isValidTransponderCode(const QString &transponderCode)
|
||||
{
|
||||
if (transponderCode.isEmpty() || transponderCode.length() > 4) return false;
|
||||
bool number;
|
||||
bool number {};
|
||||
int tc = transponderCode.toInt(&number);
|
||||
if (!number) return false;
|
||||
if (tc < 0 || tc > 7777) return false;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace swift::misc::db
|
||||
|
||||
void IDatastoreObjectWithIntegerKey::setDbKey(const QString &key)
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int k = key.toInt(&ok);
|
||||
m_dbKey = ok ? k : -1;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace swift::misc::db
|
||||
int IDatastoreObjectWithIntegerKey::stringToDbKey(const QString &candidate)
|
||||
{
|
||||
if (candidate.isEmpty()) { return invalidDbKey(); }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int k = candidate.toInt(&ok);
|
||||
return ok ? k : invalidDbKey();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ QDBusArgument &operator<<(QDBusArgument &arg, const E &value)
|
||||
template <class E, std::enable_if_t<std::is_enum_v<E>, int> = 0>
|
||||
const QDBusArgument &operator>>(const QDBusArgument &arg, E &value)
|
||||
{
|
||||
int temp;
|
||||
int temp {};
|
||||
arg.beginStructure();
|
||||
arg >> temp;
|
||||
arg.endStructure();
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace swift::misc
|
||||
else if (part.contains("port=", Qt::CaseInsensitive))
|
||||
{
|
||||
const QString p = part.mid(part.lastIndexOf("=") + 1).trimmed();
|
||||
bool ok;
|
||||
bool ok {};
|
||||
port = p.toInt(&ok);
|
||||
if (!ok) { port = -1; }
|
||||
}
|
||||
@@ -158,7 +158,7 @@ namespace swift::misc
|
||||
|
||||
bool CDBusServer::dBusAddressToHostAndPort(const QString &dbusAddress, QString &o_host, QString &o_port)
|
||||
{
|
||||
int port;
|
||||
int port {};
|
||||
const bool s = dBusAddressToHostAndPort(dbusAddress, o_host, port);
|
||||
o_port = QString::number(port);
|
||||
return s;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace swift::misc::geo
|
||||
}
|
||||
|
||||
// number only -> parsed as degrees
|
||||
bool isDouble;
|
||||
bool isDouble {};
|
||||
const double valueDegrees = wgs.toDouble(&isDouble);
|
||||
if (isDouble)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace swift::misc::geo
|
||||
while (i.hasNext() && c < 3)
|
||||
{
|
||||
const QRegularExpressionMatch match = i.next();
|
||||
bool ok;
|
||||
bool ok {};
|
||||
if (match.hasMatch())
|
||||
{
|
||||
const QString cap = match.captured(0);
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace swift::misc
|
||||
if (isFallThroughEnabled(handlers))
|
||||
{
|
||||
Q_ASSERT_X(m_oldHandler, Q_FUNC_INFO, "Handler must be installed");
|
||||
QtMsgType type;
|
||||
QtMsgType type {};
|
||||
QString category;
|
||||
QString message;
|
||||
statusMessage.toQtLogTriple(&type, &category, &message);
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace swift::misc
|
||||
|
||||
void CLogPattern::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
quint8 severities;
|
||||
quint8 severities {};
|
||||
QStringList strings;
|
||||
argument >> severities >> m_strategy >> strings;
|
||||
m_strings = QSet<QString>(strings.begin(), strings.end());
|
||||
@@ -385,7 +385,7 @@ namespace swift::misc
|
||||
|
||||
void CLogPattern::unmarshalFromDataStream(QDataStream &stream)
|
||||
{
|
||||
quint8 severities;
|
||||
quint8 severities {};
|
||||
QStringList strings;
|
||||
stream >> severities >> m_strategy >> strings;
|
||||
m_strings = QSet<QString>(strings.begin(), strings.end());
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace swift::misc::math
|
||||
double CMathUtils::round(double value, int digits)
|
||||
{
|
||||
// gosh, is there no Qt method for this??? It's year 2013
|
||||
double fractpart, intpart;
|
||||
fractpart = modf(value, &intpart);
|
||||
double intpart {};
|
||||
double fractpart = modf(value, &intpart);
|
||||
if (epsilonZeroLimits(fractpart)) { return value; } // do not mess any "integers" to the worse
|
||||
const double m = pow(10.0, digits);
|
||||
const qint64 ri = qRound64(value * m); // do not loose any range here
|
||||
@@ -30,8 +30,8 @@ namespace swift::misc::math
|
||||
double CMathUtils::roundEpsilon(double value, double epsilon)
|
||||
{
|
||||
if (epsilonZeroLimits(epsilon)) { return value; } // avoid division by 0
|
||||
double fractpart, intpart;
|
||||
fractpart = modf(value, &intpart);
|
||||
double intpart {};
|
||||
double fractpart = modf(value, &intpart);
|
||||
if (epsilonZeroLimits(fractpart)) { return value; } // do not mess any "integers" to the worse
|
||||
const double roundValue = value / epsilon;
|
||||
const qint64 ri = qRound64(roundValue);
|
||||
@@ -98,7 +98,7 @@ namespace swift::misc::math
|
||||
|
||||
QString CMathUtils::fractionalPartAsString(double value, int width)
|
||||
{
|
||||
double intpart;
|
||||
double intpart {};
|
||||
const double fractpart = modf(value, &intpart);
|
||||
const int prec = width >= 0 ? width + 1 : 10;
|
||||
const QString f = QString::number(fractpart, 'f', prec); // avoid scientific notation
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace swift::misc::math
|
||||
//! Fractional part of value
|
||||
static inline double fract(double value)
|
||||
{
|
||||
double unused;
|
||||
double unused {};
|
||||
return modf(value, &unused);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace swift::misc::network
|
||||
|
||||
bool CNetworkUtils::isValidPort(const QString &port)
|
||||
{
|
||||
bool success;
|
||||
bool success {};
|
||||
int p = port.toInt(&success);
|
||||
if (!success) return false;
|
||||
return (p >= 1 && p <= 65535);
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace swift::misc::network
|
||||
bool CUrlLogList::markAsReceived(const QNetworkReply *nwReply, bool success)
|
||||
{
|
||||
Q_ASSERT_X(nwReply, Q_FUNC_INFO, "missing reply");
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int id = nwReply->property(CUrlLog::propertyNameId()).toInt(&ok);
|
||||
return (ok && id >= 0) ? this->markAsReceived(id, success) : false;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace swift::misc::physical_quantities
|
||||
unit = unit.trimmed(); // trim after replace, not before
|
||||
|
||||
if (unit.isEmpty() || number.isEmpty()) { return v; }
|
||||
bool success;
|
||||
bool success {};
|
||||
const double numberD = parseNumber(number, success, mode);
|
||||
if (!success) { return v; }
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace swift::misc::physical_quantities
|
||||
const QString hStr = hhmm.left(2);
|
||||
const QString mStr = hhmm.right(2);
|
||||
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int h = hStr.toInt(&ok);
|
||||
if (!ok || h < 0 || h > 23) { return false; }
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace swift::misc
|
||||
for (const auto &index : QStringView { indexes }.split(';'))
|
||||
{
|
||||
if (index.isEmpty()) { continue; }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
int i = index.toInt(&ok);
|
||||
Q_ASSERT(ok);
|
||||
Q_ASSERT(i >= static_cast<int>(CPropertyIndexRef::GlobalIndexCValueObject));
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace swift::misc::simulation
|
||||
|
||||
int ISimulationEnvironmentProvider::cleanUpElevations(const ICoordinateGeodetic &referenceCoordinate, int maxNumber)
|
||||
{
|
||||
int currentMax;
|
||||
int currentMax {};
|
||||
CCoordinateGeodeticList coordinates(this->getAllElevationCoordinates(currentMax));
|
||||
if (maxNumber < 0) { maxNumber = currentMax; }
|
||||
const int size = coordinates.size();
|
||||
@@ -390,8 +390,8 @@ namespace swift::misc::simulation
|
||||
const int m = foundMissed.second;
|
||||
const double hitRatioPercent = 100.0 * static_cast<double>(f) / static_cast<double>(f + m);
|
||||
|
||||
int elvGnd;
|
||||
int elv;
|
||||
int elvGnd {};
|
||||
int elv {};
|
||||
{
|
||||
QReadLocker l(&m_lockElvCoordinates);
|
||||
elvGnd = m_elvCoordinatesGnd.sizeInt();
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace swift::misc
|
||||
static bool canHandleIndex(CPropertyIndexRef index);
|
||||
|
||||
//! Constructor
|
||||
ITimestampWithOffsetBased() : ITimestampBased() {}
|
||||
ITimestampWithOffsetBased() = default;
|
||||
|
||||
//! Constructor
|
||||
ITimestampWithOffsetBased(qint64 msSincePoch) : ITimestampBased(msSincePoch) {}
|
||||
|
||||
@@ -543,7 +543,7 @@ namespace swift::misc
|
||||
else if (QMetaType(localUserType).flags() & QMetaType::IsEnumeration)
|
||||
{
|
||||
arg.beginStructure();
|
||||
int i;
|
||||
int i {};
|
||||
arg >> i;
|
||||
arg.endStructure();
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ namespace swift::misc
|
||||
template <typename F>
|
||||
static CWorker *fromTask(QObject *owner, const QString &name, F &&task)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
int typeId = qMetaTypeId<std::decay_t<decltype(std::forward<F>(task)())>>();
|
||||
return fromTaskImpl(owner, name, typeId, [task = std::forward<F>(task)]() mutable {
|
||||
if constexpr (std::is_void_v<decltype(task())>)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace swift::simplugin::flightgear
|
||||
InterfaceName(), connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
bool s {};
|
||||
s = connection.connect(
|
||||
QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.service", "aircraftModelChanged", this,
|
||||
SIGNAL(aircraftModelChanged(QString, QString, QString, QString, QString, QString, QString)));
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace swift::simplugin::flightgear
|
||||
connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
bool s {};
|
||||
s = connection.connect(QString(), "/fgswiftbus/traffic", "org.swift_project.fgswiftbus.traffic", "simFrame",
|
||||
this, SIGNAL(simFrame()));
|
||||
Q_ASSERT(s);
|
||||
|
||||
@@ -1133,7 +1133,7 @@ namespace swift::simplugin::xplane
|
||||
|
||||
void CSimulatorXPlane::onXSwiftBusSettingsChanged()
|
||||
{
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const CXSwiftBusSettings xPlaneSide = this->receiveXSwiftBusSettings(ok);
|
||||
if (ok)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace swift::simplugin::xplane
|
||||
InterfaceName(), connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
bool s {};
|
||||
s = connection.connect(
|
||||
QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service", "aircraftModelChanged", this,
|
||||
SIGNAL(aircraftModelChanged(QString, QString, QString, QString, QString, QString, QString)));
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace swift::simplugin::xplane
|
||||
connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
bool s {};
|
||||
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic", "simFrame",
|
||||
this, SIGNAL(simFrame()));
|
||||
Q_ASSERT(s);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace swift::simplugin::xplane
|
||||
int CSimulatorXPlaneConfigWindow::marginToInt(const QString &text, int defaultValue)
|
||||
{
|
||||
if (text.isEmpty()) { return defaultValue; }
|
||||
bool ok;
|
||||
bool ok {};
|
||||
const int v = text.toInt(&ok);
|
||||
return ok ? v : defaultValue;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace swift::sound::codecs
|
||||
{
|
||||
COpusDecoder::COpusDecoder(int sampleRate, int channels) : m_channels(channels)
|
||||
{
|
||||
int error;
|
||||
int error {};
|
||||
m_opusDecoder = opus_decoder_create(sampleRate, channels, &error);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace swift::sound::codecs
|
||||
{
|
||||
COpusEncoder::COpusEncoder(int sampleRate, int channels, int application)
|
||||
{
|
||||
int error;
|
||||
int error {};
|
||||
opusEncoder = opus_encoder_create(sampleRate, channels, application, &error);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace swift::sound::wav
|
||||
WAVEHeader wave; //!< WAVE header
|
||||
};
|
||||
|
||||
CWavFile::CWavFile(QObject *parent) : QFile(parent), m_headerLength(0) {}
|
||||
CWavFile::CWavFile(QObject *parent) : QFile(parent) {}
|
||||
|
||||
bool CWavFile::open(const QString &fileName)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace swift::sound::wav
|
||||
if (qFromLittleEndian<quint32>(header.wave.descriptor.size) > sizeof(WAVEHeader))
|
||||
{
|
||||
// Extended data available
|
||||
quint16 extraFormatBytes;
|
||||
quint16 extraFormatBytes {};
|
||||
if (peek((char *)&extraFormatBytes, sizeof(quint16)) != sizeof(quint16)) return false;
|
||||
const qint64 throwAwayBytes = sizeof(quint16) + qFromLittleEndian<quint16>(extraFormatBytes);
|
||||
if (read(throwAwayBytes).size() != throwAwayBytes) return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace swift::sound::wav
|
||||
bool readHeader();
|
||||
|
||||
QAudioFormat m_fileFormat;
|
||||
qint64 m_headerLength;
|
||||
qint64 m_headerLength { 0 };
|
||||
QByteArray m_audioData;
|
||||
};
|
||||
} // namespace swift::sound::wav
|
||||
|
||||
Reference in New Issue
Block a user