Fix cppcheck and compiler warnings

This commit is contained in:
Mat Sutcliffe
2020-06-18 23:48:58 +01:00
parent 9309beefc4
commit 670b1a1986
61 changed files with 131 additions and 153 deletions

View File

@@ -49,8 +49,7 @@ namespace BlackGui
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
ui->setupUi(this);
this->setModeLogin(true);
const CUrl url(sGui->getGlobalSetup().getDbHomePageUrl());
const QString urlString = asHyperlink(url.getFullUrl());
const QString urlString = asHyperlink(sGui->getGlobalSetup().getDbHomePageUrl().getFullUrl());
QString html = ui->tbr_InfoAndHints->toHtml();
html = html.replace("##swiftDB##", urlString, Qt::CaseInsensitive);
html = html.replace("##swiftEnableSSO##", urlString, Qt::CaseInsensitive);

View File

@@ -1015,7 +1015,6 @@ namespace BlackGui
void CFlightPlanComponent::setRemarksUIValues(const QString &remarks)
{
if (remarks.isEmpty()) { return; }
const QString r = remarks.toUpper();
if (remarks.contains("/V"))
{

View File

@@ -310,11 +310,7 @@ namespace BlackGui
void CLoginAdvComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft)
{
const QString ac(
ownAircraft.getAircraftIcaoCodeDesignator() %
(ownAircraft.hasAirlineDesignator() ? (u' ' % ownAircraft.getAirlineIcaoCodeDesignator()) : QString()) %
(ownAircraft.hasModelString() ? (u' ' % ownAircraft.getModelString()) : QString())
);
Q_UNUSED(ownAircraft)
}
CServer CLoginAdvComponent::getCurrentVatsimServer() const
@@ -382,7 +378,6 @@ namespace BlackGui
// in any case override if connected
ui->comp_OwnAircraft->setOwnModelAndIcaoValues();
const CServer server = nwc->getConnectedServer();
ui->comp_NetworkDetails->setLoginMode(nwc->getLoginMode());
const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
this->setGuiLoginAsValues(ownAircraft);

View File

@@ -133,8 +133,8 @@ namespace BlackGui
ui->tvp_ResultMessages->insert(m);
return;
}
CSimulatorInfo simulator = models.simulatorsWithMaxEntries();
m_matcher.setModelSet(models, simulator, true);
CSimulatorInfo si = models.simulatorsWithMaxEntries();
m_matcher.setModelSet(models, si, true);
}
else
{
@@ -150,7 +150,7 @@ namespace BlackGui
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue());
}
void CModelMatcherComponent::onCacheChanged(CSimulatorInfo &simulator)
void CModelMatcherComponent::onCacheChanged(const CSimulatorInfo &simulator)
{
Q_UNUSED(simulator);
this->redisplay();

View File

@@ -61,7 +61,7 @@ namespace BlackGui
void onWorkbenchToggled(bool checked);
//! Cache changed
void onCacheChanged(BlackMisc::Simulation::CSimulatorInfo &simulator);
void onCacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Web data have been read
void onWebDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number, const QUrl &url);

View File

@@ -179,8 +179,6 @@ namespace BlackGui
void CNetworkDetailsComponent::onSelectedServerChanged(const CServer &server)
{
if (!m_updatePilotOnServerChanges) { return; }
const bool vatsim = this->isVatsimServerSelected();
const CUser user = vatsim ? this->getCurrentVatsimServer().getUser() : server.getUser();
emit this->overridePilot(server.getUser());
}

View File

@@ -295,7 +295,7 @@ namespace BlackGui
// in which North=(1,0) and East=(-1,0)
// but we want North=(0,-1) and East=(0,1)
// (QGraphicsView y axis increases downwards)
qSwap(p.rx(), p.ry());
std::swap(p.rx(), p.ry());
p.setX(-p.x());
p.setY(-p.y());
return p;

View File

@@ -98,7 +98,6 @@ namespace BlackGui
const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
const QStringList familySizeStyle = this->getFamilySizeStyle();
QString fontColor = m_selectedColor.name();
if (!m_selectedColor.isValid() || m_selectedColor.name().isEmpty())
{

View File

@@ -101,6 +101,7 @@ namespace BlackGui
else
{
qFatal("Wrong sender");
// cppcheck-suppress duplicateBreak
return;
}

View File

@@ -88,8 +88,6 @@ namespace BlackGui
CAircraftCategory CAircraftCategoryTreeView::selectedObject() const
{
const QModelIndex index = this->currentIndex();
const QVariant data = this->model()->data(index.siblingAtColumn(0));
const CAircraftCategoryTreeModel *model = this->categoryModel();
if (!model) { return CAircraftCategory(); }
return model->container().frontOrDefault();

View File

@@ -706,10 +706,10 @@ namespace BlackGui
int removeIf(K0 k0, V0 v0, KeysValues... keysValues)
{
if (this->rowCount() < 1) { return 0; }
ContainerType copy(container());
int r = copy.removeIf(k0, v0, keysValues...);
ContainerType cp(container());
int r = cp.removeIf(k0, v0, keysValues...);
if (r < 1) { return 0; }
this->updateContainerMaybeAsync(copy);
this->updateContainerMaybeAsync(cp);
return r;
}
@@ -717,9 +717,9 @@ namespace BlackGui
template <class K1, class V1>
void replaceOrAdd(K1 key1, V1 value1, const ObjectType &replacement)
{
ContainerType copy(container());
copy.replaceOrAdd(key1, value1, replacement);
this->updateContainerMaybeAsync(copy);
ContainerType cp(container());
cp.replaceOrAdd(key1, value1, replacement);
this->updateContainerMaybeAsync(cp);
}
//! \name Slot overrides from base class