Cppcheck warnings.

This commit is contained in:
Roman Telezhynskyi 2022-01-29 18:27:17 +02:00
parent 28b4874441
commit 882f4ba0bf
8 changed files with 21 additions and 15 deletions

View File

@ -218,16 +218,16 @@ auto VPSheetSceneData::RotationControls() const -> VPGraphicsPieceControls *
//---------------------------------------------------------------------------------------------------------------------
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
{
VPGraphicsPiece *_graphicsPiece = nullptr;
for(auto *graphicPiece : m_graphicsPieces)
auto _graphicsPiece =
std::find_if(m_graphicsPieces.begin(), m_graphicsPieces.end(),
[piece](VPGraphicsPiece *graphicPiece) { return graphicPiece->GetPiece() == piece; });
if (_graphicsPiece != m_graphicsPieces.end())
{
if(graphicPiece->GetPiece() == piece)
{
_graphicsPiece = graphicPiece;
}
return *_graphicsPiece;
}
return _graphicsPiece;
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -1373,7 +1373,11 @@ QSharedPointer<VMeasurements> MainWindowsNoGUI::OpenMeasurementFile(const QStrin
{
qCCritical(vMainNoGUIWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
m->clear();
if (not m.isNull())
{
m->clear();
}
if (not VApplication::IsGUIMode())
{
qApp->exit(V_EX_NOINPUT);

View File

@ -93,6 +93,7 @@ QString compilerString()
{
return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15));
}
return QLatin1String("MSVC <unknown version>");
#else
return QStringLiteral("<unknown compiler>");
#endif

View File

@ -223,7 +223,8 @@ bool VPE::VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) c
{
if (QFile::exists(tmpUrl.toLocalFile()))
{
tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break;
tmpFileInfo = QFileInfo(tmpUrl.toLocalFile());
break;
}
}

View File

@ -85,7 +85,7 @@ signals:
public slots:
void ActivateControls(const QUuid &id);
void DeactivateControls(QGraphicsItem* pItem);
void DeactivateControls(QGraphicsItem* item);
void UpdateControls();
protected:

View File

@ -452,7 +452,7 @@ void VBackgroundImageItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *even
//---------------------------------------------------------------------------------------------------------------------
void VBackgroundImageItem::keyPressEvent(QKeyEvent *event)
{
const int move = event->modifiers() & Qt::ShiftModifier ? 10 : 1;
const int move = (event->modifiers() & Qt::ShiftModifier) ? 10 : 1;
if (event->key() == Qt::Key_Left)
{
TranslateImageOn(-move, 0);

View File

@ -604,7 +604,7 @@ int FancyTabBar::CurrentIndex() const
}
//---------------------------------------------------------------------------------------------------------------------
void FancyTabBar::SetTabToolTip(int index, QString toolTip)
void FancyTabBar::SetTabToolTip(int index, const QString &toolTip)
{
m_attachedTabs[index]->m_toolTip = toolTip;
}
@ -628,7 +628,7 @@ QString FancyTabBar::TabText(int index) const
}
//---------------------------------------------------------------------------------------------------------------------
void FancyTabBar::SetTabText(int index, QString text)
void FancyTabBar::SetTabText(int index, const QString &text)
{
m_attachedTabs.at(index)->m_text=text;
setMaximumWidth(TabSizeHint(false).width());

View File

@ -69,13 +69,13 @@ public:
void SetCurrentIndex(int index);
int CurrentIndex() const;
void SetTabToolTip(int index, QString toolTip);
void SetTabToolTip(int index, const QString &toolTip);
QString TabToolTip(int index) const;
QIcon TabIcon(int index) const;
QString TabText(int index) const;
void SetTabText(int index, QString text);
void SetTabText(int index, const QString &text);
int Count() const;
QRect TabRect(int index) const;