diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index fd4b07c3e..6628d1d08 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -228,7 +228,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con } //--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress uninitMemberVar MApplication::MApplication(int &argc, char **argv) :VAbstractApplication(argc, argv), mainWindows(), diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 1a632e3be..397ada752 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -574,8 +574,7 @@ void TMainWindow::FileSave() else { QString error; - bool result = SaveMeasurements(curFile, error); - if (not result) + if (not SaveMeasurements(curFile, error)) { QMessageBox messageBox; messageBox.setIcon(QMessageBox::Warning); @@ -1534,9 +1533,7 @@ void TMainWindow::SaveMValue() return; } - const bool ok = EvalFormula(text, true, meash->GetData(), ui->labelCalculatedValue); - - if (not ok) + if (not EvalFormula(text, true, meash->GetData(), ui->labelCalculatedValue)) { return; } diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 6ddb5c78f..cc38efc40 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -615,9 +615,7 @@ void DialogIncrements::SaveIncrFormula() } QSharedPointer incr = data->GetVariable(nameField->text()); - const bool ok = EvalIncrementFormula(text, true, incr->GetData(), ui->labelCalculatedValue); - - if (not ok) + if (not EvalIncrementFormula(text, true, incr->GetData(), ui->labelCalculatedValue)) { return; } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 9a3169d1a..6ddceb81c 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1021,7 +1021,7 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & SCASSERT(scene != nullptr); Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); - VToolBasePoint *spoint = 0; + VToolBasePoint *spoint = nullptr; try { quint32 id = 0; @@ -1034,7 +1034,7 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0")); VPointF *point = new VPointF(x, y, name, mx, my); - VToolBasePoint::Create(id, nameActivPP, point, scene, this, data, parse, Source::FromFile); + spoint = VToolBasePoint::Create(id, nameActivPP, point, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index 3f057de70..1609ed214 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -262,7 +262,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const { if (ver < MinVer()) { // Version less than minimally supported version. Can't do anything. - throw e; + throw; } else if (ver > MaxVer()) { // Version bigger than maximum supported version. We still have a chance to open the file. @@ -278,7 +278,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const } else { // Unexpected version. Most time mean that we do not catch all versions between min and max. - throw e; + throw; } return; // All is fine and we can try to convert to current max version. diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 5818b4aaa..59c4cb9ba 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1218,30 +1218,19 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) switch (tags.indexOf(tag)) { case 0: //TagUnit - { - return QDomElement(); - break;// Mandatory tag - } + return QDomElement();// Mandatory tag case 1: //TagImage - { element = createElement(TagImage); break; - } case 2: //TagAuthor - { element = createElement(TagAuthor); break; - } case 3: //TagDescription - { element = createElement(TagDescription); break; - } case 4: //TagNotes - { element = createElement(TagNotes); break; - } case 5: //TagGradation { element = createElement(TagGradation); @@ -1256,46 +1245,28 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) break; } case 6: // TagPatternName - { element = createElement(TagPatternName); break; - } case 7: // TagPatternNum - { element = createElement(TagPatternNum); break; - } case 8: // TagCompanyName - { element = createElement(TagCompanyName); break; - } case 9: // TagCustomerName - { element = createElement(TagCustomerName); break; - } case 10: // TagSize - { element = createElement(TagSize); break; - } case 11: // TagShowDate - { element = createElement(TagShowDate); break; - } case 12: // TagShowMeasurements - { element = createElement(TagShowMeasurements); break; - } - default: - { return QDomElement(); - break; - } } InsertTag(tags, element); return element; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 11eaef7cc..16acd4bda 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -351,13 +351,13 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement) const { Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); - quint32 id = 0; + quint32 id = NULL_ID; - QString message = tr("Got wrong parameter id. Need only id > 0."); + const QString message = tr("Got wrong parameter id. Need only id > 0."); try { id = GetParametrUInt(domElement, VDomDocument::AttrId, NULL_ID_STR); - if (id <= 0) + if (id == NULL_ID) { throw VExceptionWrongId(message, domElement); } diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 46b0711c1..ae756c2f0 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -50,7 +50,7 @@ class QMUPARSERSHARED_EXPORT QmuParserTester : public QObject // final public: typedef int ( QmuParserTester::*testfun_type ) (); - QmuParserTester(QObject *parent = nullptr); + explicit QmuParserTester(QObject *parent = nullptr); private slots: void Run(); diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 32681dd0d..cc5eff4d4 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -172,12 +172,12 @@ bool DL_Dxf::in(std::stringstream& stream, */ bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) { - static int line = 1; - // Read one group of the DXF file and strip the lines: if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, fp) && DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, fp, false) ) { + static int line = 1; + groupCode = static_cast(toInt(groupCodeTmp)); creationInterface->processCodeValuePair(groupCode, groupValue); @@ -196,12 +196,11 @@ bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) bool DL_Dxf::readDxfGroups(std::stringstream& stream, DL_CreationInterface* creationInterface) { - static int line = 1; - // Read one group of the DXF file and chop the lines: if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, stream) && DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream, false) ) { + static int line = 1; groupCode = static_cast(toInt(groupCodeTmp)); diff --git a/src/libs/vgeometry/varc_p.h b/src/libs/vgeometry/varc_p.h index f6aac25b7..99cb4f2c0 100644 --- a/src/libs/vgeometry/varc_p.h +++ b/src/libs/vgeometry/varc_p.h @@ -43,7 +43,7 @@ class VArcData : public QSharedData public: VArcData(); VArcData(qreal radius, QString formulaRadius); - VArcData(qreal radius); + explicit VArcData(qreal radius); VArcData(const VArcData &arc); virtual ~VArcData(); diff --git a/src/libs/vgeometry/vellipticalarc.h b/src/libs/vgeometry/vellipticalarc.h index 064060a86..b9f0ff545 100644 --- a/src/libs/vgeometry/vellipticalarc.h +++ b/src/libs/vgeometry/vellipticalarc.h @@ -81,6 +81,7 @@ protected: private: QSharedDataPointer d; + // cppcheck-suppress unusedPrivateFunction QVector GetAngles () const; qreal MaxLength() const; QPointF GetPoint (qreal angle) const; diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index aae990633..eb7b33ccc 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -681,7 +681,7 @@ void VLayoutDetail::SetMirror(bool value) * @param dAng angle of rotation * @return position of point pt after rotating it around the center for dAng radians */ -QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) const +QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) { QPointF ptDest; QPointF ptRel = pt - ptCenter; @@ -723,10 +723,10 @@ QVector VLayoutDetail::Mirror(const QVector &points) const * @param pt2 second point * @return Euclidian distance between the two points */ -qreal VLayoutDetail::GetDistance(const QPointF &pt1, const QPointF &pt2) const +qreal VLayoutDetail::GetDistance(const QPointF &pt1, const QPointF &pt2) { - qreal dX = pt1.x() - pt2.x(); - qreal dY = pt1.y() - pt2.y(); + const qreal dX = pt1.x() - pt2.x(); + const qreal dY = pt1.y() - pt2.y(); return qSqrt(dX*dX + dY*dY); } diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 56cb5aff0..602d84cd1 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -100,9 +100,9 @@ private: QVector Map(const QVector &points) const; static QVector RoundPoints(const QVector &points); - QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng) const; + static QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng); QVector Mirror(const QVector& points) const; - qreal GetDistance(const QPointF& pt1, const QPointF& pt2) const; + static qreal GetDistance(const QPointF& pt1, const QPointF& pt2); }; Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE); diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 62de75761..06c986db6 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -18,7 +18,7 @@ TextLine::TextLine() * @brief VTextManager::VTextManager constructor */ VTextManager::VTextManager() - :m_font(), m_liLines(), m_liOutput() + :m_font(), m_liLines(), m_liOutput() {} //--------------------------------------------------------------------------------------------------------------------- @@ -327,7 +327,7 @@ QStringList VTextManager::SplitString(const QString &qs, qreal fW, const QFontMe { if (qsCurrent.length() > 0) { - qsCurrent += QLatin1Literal(" "); + qsCurrent += QLatin1String(" "); } // check if another word can be added into current line if (fm.width(qsCurrent + qslWords[i]) > fW) diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index aea6741ab..e36287899 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -51,7 +51,7 @@ public: void Update(const VAbstractPattern* pDoc); protected: - QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); + static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); private: QFont m_font; diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index ab620ce3f..033aa8571 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -88,8 +88,9 @@ QString compilerString() { return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); } +#else + return QStringLiteral(""); #endif - return QLatin1String(""); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index a413a066c..2b728f797 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -90,7 +90,7 @@ QxtCsvModel::QxtCsvModel(QIODevice *file, QObject *parent, bool withHeader, QCha \sa setSource */ -QxtCsvModel::QxtCsvModel(const QString filename, QObject *parent, bool withHeader, QChar separator) +QxtCsvModel::QxtCsvModel(const QString &filename, QObject *parent, bool withHeader, QChar separator) : QAbstractTableModel(parent) { QXT_INIT_PRIVATE(QxtCsvModel); @@ -176,7 +176,7 @@ QVariant QxtCsvModel::headerData(int section, Qt::Orientation orientation, int r Reads in a CSV file from the provided \a file using \a codec. */ -void QxtCsvModel::setSource(const QString filename, bool withHeader, QChar separator, QTextCodec* codec) +void QxtCsvModel::setSource(const QString &filename, bool withHeader, QChar separator, QTextCodec* codec) { QFile src(filename); setSource(&src, withHeader, separator, codec); @@ -194,6 +194,7 @@ void QxtCsvModel::setSource(const QString filename, bool withHeader, QChar separ void QxtCsvModel::setSource(QIODevice *file, bool withHeader, QChar separator, QTextCodec* codec) { QxtCsvModelPrivate* d_ptr = &qxt_d(); + // cppcheck-suppress unreadVariable bool headerSet = !withHeader; if (not file->isOpen()) { @@ -653,7 +654,7 @@ void QxtCsvModel::toCSV(QIODevice* dest, bool withHeader, QChar separator, QText Fields in the output file will be separated by \a separator. Set \a withHeader to true to output a row of headers at the top of the file. */ -void QxtCsvModel::toCSV(const QString filename, bool withHeader, QChar separator, QTextCodec* codec) const +void QxtCsvModel::toCSV(const QString &filename, bool withHeader, QChar separator, QTextCodec* codec) const { QFile dest(filename); toCSV(&dest, withHeader, separator, codec); @@ -695,6 +696,7 @@ void QxtCsvModel::setQuoteMode(QuoteMode mode) */ void QxtCsvModel::setText(int row, int column, const QString& value) { +// cppcheck-suppress indexCalled setData(index(row, column), value); } @@ -705,6 +707,7 @@ void QxtCsvModel::setText(int row, int column, const QString& value) */ QString QxtCsvModel::text(int row, int column) const { +// cppcheck-suppress indexCalled return data(index(row, column)).toString(); } diff --git a/src/libs/vmisc/qxtcsvmodel.h b/src/libs/vmisc/qxtcsvmodel.h index 18869fd89..34858cdfc 100644 --- a/src/libs/vmisc/qxtcsvmodel.h +++ b/src/libs/vmisc/qxtcsvmodel.h @@ -46,9 +46,9 @@ class QxtCsvModel : public QAbstractTableModel { Q_OBJECT public: - QxtCsvModel(QObject *parent = nullptr); + explicit QxtCsvModel(QObject *parent = nullptr); explicit QxtCsvModel(QIODevice *file, QObject *parent = nullptr, bool withHeader = false, QChar separator = ','); - explicit QxtCsvModel(const QString filename, QObject *parent = nullptr, bool withHeader = false, + explicit QxtCsvModel(const QString &filename, QObject *parent = nullptr, bool withHeader = false, QChar separator = ','); virtual ~QxtCsvModel(); @@ -82,10 +82,11 @@ public: virtual bool removeColumns(int col, int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE; void setSource(QIODevice *file, bool withHeader = false, QChar separator = ',', QTextCodec* codec = nullptr); - void setSource(const QString filename, bool withHeader = false, QChar separator = ',', QTextCodec* codec = nullptr); + void setSource(const QString &filename, bool withHeader = false, QChar separator = ',', + QTextCodec* codec = nullptr); void toCSV(QIODevice *file, bool withHeader = false, QChar separator = ',', QTextCodec* codec = nullptr) const; - void toCSV(const QString filename, bool withHeader = false, QChar separator = ',', + void toCSV(const QString &filename, bool withHeader = false, QChar separator = ',', QTextCodec* codec = nullptr) const; enum QuoteOption { NoQuotes = 0, diff --git a/src/libs/vobj/delaunay.cpp b/src/libs/vobj/delaunay.cpp index 5a37936d8..9536de729 100644 --- a/src/libs/vobj/delaunay.cpp +++ b/src/libs/vobj/delaunay.cpp @@ -134,6 +134,7 @@ static point2d_t* point_alloc() p = (point2d_t*)malloc(sizeof(point2d_t)); assert( p != NULL ); +// cppcheck-suppress memsetClassFloat memset(p, 0, sizeof(point2d_t)); return p; diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 102b67165..4c6fe32a4 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -784,7 +784,7 @@ QString VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSeparator) const +QString VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSeparator) { try { diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index 079d1ae50..9684af812 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -54,7 +54,7 @@ public: QString PostfixOperator(const QString &name) const; QString FormulaFromUser(const QString &formula, bool osSeparator) const; - QString TryFormulaFromUser(const QString &formula, bool osSeparator) const; + static QString TryFormulaFromUser(const QString &formula, bool osSeparator); QString FormulaToUser(const QString &formula, bool osSeparator) const; virtual void Retranslate() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 1ebb410b0..a975558b2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -599,6 +599,7 @@ bool VToolSplinePath::IsMovable(int index) const const auto splPath = VAbstractTool::data.GeometricObject(id); //index == -1 - can delete, but decided to left + // cppcheck-suppress redundantCondition if (index == -1 || index < 1 || index > splPath->CountSubSpl()) { return false; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index 85405cf8e..9e2966af8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -46,10 +46,9 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu const QString &lineColor, const QString &formula, const quint32 &basePointId, const qreal &angle, QGraphicsItem *parent) :VToolSinglePoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId), - mainLine(nullptr), lineColor(ColorBlack) + mainLine(nullptr), lineColor(lineColor) { this->typeLine = typeLine; - this->lineColor = lineColor; Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712 QPointF point1 = *data->GeometricObject(basePointId); QPointF point2 = *data->GeometricObject(id); diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index a408c4459..f6aa4beac 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -49,10 +49,9 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3 const QString &typeLine, const QString &lineColor, const Source &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), - lineColor(ColorBlack) + lineColor(lineColor) { this->typeLine = typeLine; - this->lineColor = lineColor; //Line const QSharedPointer first = data->GeometricObject(firstPoint); const QSharedPointer second = data->GeometricObject(secondPoint); diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index ad74b4cf4..a3a2edcb7 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -306,7 +306,7 @@ void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VAbstractP } quint32 cursor = doc->getCursor(); - if (cursor <= 0) + if (cursor == NULL_ID) { history->append(record); } diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index aa312ca32..5314a7d2a 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -91,15 +91,14 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->fillRect(option->rect, QColor(251, 251, 175)); painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); - // draw text lines - int iY = 0; - int iH = 0; painter->setPen(Qt::black); QFont fnt = m_tm.GetFont(); for (int i = 0; i < m_tm.GetCount(); ++i) { const TextLine& tl = m_tm.GetLine(i); - iH = tl.m_iHeight; + // draw text lines + int iY = 0; + int iH = tl.m_iHeight; fnt.setPixelSize(m_tm.GetFont().pixelSize() + tl.m_iFontSize); fnt.setWeight(tl.m_eFontWeight); fnt.setStyle(tl.m_eStyle); @@ -562,7 +561,7 @@ QRectF VTextGraphicsItem::GetBoundingRect(QRectF rectBB, qreal dRot) const qreal dY1 = 0; qreal dY2 = 0; - double dAng = qDegreesToRadians(dRot); + double dAng = qDegreesToRadians(dRot); for (int i = 0; i < 4; ++i) { QPointF pt = apt[i] - ptCenter; diff --git a/src/libs/vtools/tools/vtextgraphicsitem.h b/src/libs/vtools/tools/vtextgraphicsitem.h index c86b1a639..c601cc1e7 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.h +++ b/src/libs/vtools/tools/vtextgraphicsitem.h @@ -52,8 +52,8 @@ class VTextGraphicsItem : public QGraphicsObject }; public: - VTextGraphicsItem(QGraphicsItem* pParent = 0); - ~VTextGraphicsItem(); + explicit VTextGraphicsItem(QGraphicsItem* pParent = nullptr); + virtual ~VTextGraphicsItem(); void SetFont(const QFont& fnt); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index dffd23f26..7e650b141 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -525,7 +525,6 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d VContainer *data, const Document &parse, const Source &typeCreation, bool retainPieces) { - VToolUnionDetails *unionDetails = 0; quint32 id = _id; QString drawName; if (typeCreation == Source::FromGui) @@ -546,10 +545,12 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d if (parse == Document::FullParse) { //Scene doesn't show this tool, so doc will destroy this object. - unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, drawName, doc); + VToolUnionDetails *unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, + drawName, doc); doc->AddTool(id, unionDetails); // Unfortunatelly doc will destroy all objects only in the end, but we should delete them before each FullParse doc->AddToolOnRemove(unionDetails); + return unionDetails; } //Then create new details VNodeDetail det1p1; diff --git a/src/libs/vtools/undocommands/addtocalc.cpp b/src/libs/vtools/undocommands/addtocalc.cpp index 4e5ab15a5..904d72992 100644 --- a/src/libs/vtools/undocommands/addtocalc.cpp +++ b/src/libs/vtools/undocommands/addtocalc.cpp @@ -89,7 +89,7 @@ void AddToCalc::redo() QDomElement calcElement; if (doc->GetActivNodeElement(VAbstractPattern::TagCalculation, calcElement)) { - if (cursor <= 0) + if (cursor == NULL_ID) { calcElement.appendChild(xml); }