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
src
app
puzzle/layout
valentina
libs

View File

@ -218,16 +218,16 @@ auto VPSheetSceneData::RotationControls() const -> VPGraphicsPieceControls *
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece * auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
{ {
VPGraphicsPiece *_graphicsPiece = nullptr; auto _graphicsPiece =
for(auto *graphicPiece : m_graphicsPieces) 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) return *_graphicsPiece;
{
_graphicsPiece = graphicPiece;
}
} }
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.")), qCCritical(vMainNoGUIWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
if (not m.isNull())
{
m->clear(); m->clear();
}
if (not VApplication::IsGUIMode()) if (not VApplication::IsGUIMode())
{ {
qApp->exit(V_EX_NOINPUT); 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 ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15));
} }
return QLatin1String("MSVC <unknown version>");
#else #else
return QStringLiteral("<unknown compiler>"); return QStringLiteral("<unknown compiler>");
#endif #endif

View File

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

View File

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

View File

@ -452,7 +452,7 @@ void VBackgroundImageItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *even
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBackgroundImageItem::keyPressEvent(QKeyEvent *event) 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) if (event->key() == Qt::Key_Left)
{ {
TranslateImageOn(-move, 0); 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; 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; m_attachedTabs.at(index)->m_text=text;
setMaximumWidth(TabSizeHint(false).width()); setMaximumWidth(TabSizeHint(false).width());

View File

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