diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 233ba7386..fa9619427 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -472,13 +472,14 @@ QString VApplication::LogPath() const } //--------------------------------------------------------------------------------------------------------------------- -void VApplication::CreateLogDir() const +bool VApplication::CreateLogDir() const { QDir logDir(LogDirPath()); if (logDir.exists() == false) { - logDir.mkpath("."); // Create directory for log if need + return logDir.mkpath("."); // Create directory for log if need } + return true; } //--------------------------------------------------------------------------------------------------------------------- @@ -600,12 +601,14 @@ QStringList VApplication::LabelLanguages() //--------------------------------------------------------------------------------------------------------------------- void VApplication::StartLogging() { - CreateLogDir(); - BeginLogging(); - ClearOldLogs(); + if (CreateLogDir()) + { + BeginLogging(); + ClearOldLogs(); #if defined(Q_OS_WIN) && defined(Q_CC_GNU) - ClearOldReports(); + ClearOldReports(); #endif // defined(Q_OS_WIN) && defined(Q_CC_GNU) + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index f2704aaa4..87b9bb9cc 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -109,7 +109,7 @@ private: QString LogDirPath()const; QString LogPath()const; - void CreateLogDir()const; + bool CreateLogDir()const; void BeginLogging(); void ClearOldLogs()const; diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index 27a9312c0..a04ab5b3f 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -170,7 +170,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select) const quint32 id = item->data(Qt::UserRole).toUInt(); if (allDetails->contains(id)) { - if (not select == allDetails->value(id).IsInLayout()) + if (not (select == allDetails->value(id).IsInLayout())) { TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::UpdateList, this, &VWidgetDetails::UpdateList); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 52ef03972..affb3b1b2 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1498,7 +1498,7 @@ void MainWindow::LoadStandard() if (qApp->patternType() == MeasurementsType::Standard) { - if (not hText.isEmpty() && not gradationSizes.isNull()) + if (not hText.isEmpty() && not gradationHeights.isNull()) { gradationHeights->setCurrentText(hText); } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c7c4b3678..871239d8e 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -41,6 +41,7 @@ #include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionobjecterror.h" +#include "../exception/vexceptionconversionerror.h" #include "../qmuparser/qmutokenparser.h" #include "../ifc/exception/vexceptionbadid.h" #include "../ifc/ifcdef.h" @@ -2263,33 +2264,40 @@ QMap > VAbstractPattern::GetGroups() { QMap > data; - QDomElement groups = CreateGroups(); - if (not groups.isNull()) + try { - QDomNode domNode = groups.firstChild(); - while (domNode.isNull() == false) + QDomElement groups = CreateGroups(); + if (not groups.isNull()) { - if (domNode.isElement()) + QDomNode domNode = groups.firstChild(); + while (domNode.isNull() == false) { - const QDomElement group = domNode.toElement(); - if (group.isNull() == false) + if (domNode.isElement()) { - if (group.tagName() == TagGroup) + const QDomElement group = domNode.toElement(); + if (group.isNull() == false) { - const quint32 id = GetParametrUInt(group, AttrId, "0"); - const bool visible = GetParametrBool(group, AttrVisible, trueStr); - const QString name = GetParametrString(group, AttrName, tr("New group")); + if (group.tagName() == TagGroup) + { + const quint32 id = GetParametrUInt(group, AttrId, "0"); + const bool visible = GetParametrBool(group, AttrVisible, trueStr); + const QString name = GetParametrString(group, AttrName, tr("New group")); - data.insert(id, qMakePair(name, visible)); + data.insert(id, qMakePair(name, visible)); + } } } + domNode = domNode.nextSibling(); } - domNode = domNode.nextSibling(); + } + else + { + qDebug("Can't get tag Groups."); } } - else + catch (const VExceptionConversionError &) { - qDebug("Can't get tag Groups."); + return QMap >(); } return data; diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 4d3d0b428..2e0e3153d 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -2556,7 +2556,7 @@ DL_WriterA* DL_Dxf::out(const char* file, DL_Codes::version version) { const size_t size = strlen(file)+1; char* f = new char[size]; - strlcpy(f, file, size); // Strange thing the sizeof(f) doesn't return correct value + strlcpy(f, file, size); this->version = version; DL_WriterA* dw = new DL_WriterA(f, version); @@ -5925,19 +5925,21 @@ int DL_Dxf::getLibVersion(const std::string& str) */ void DL_Dxf::test() { - char* buf1 = new char[10]; - char* buf2 = new char[10]; - char* buf3 = new char[10]; - char* buf4 = new char[10]; - char* buf5 = new char[10]; - char* buf6 = new char[10]; + const size_t bufSize = 10; - strlcpy(buf1, " 10\n", sizeof(buf1)); - strlcpy(buf2, "10", sizeof(buf2)); - strlcpy(buf3, "10\n", sizeof(buf3)); - strlcpy(buf4, " 10 \n", sizeof(buf4)); - strlcpy(buf5, " 10 \r", sizeof(buf5)); - strlcpy(buf6, "\t10 \n", sizeof(buf6)); + char* buf1 = new char[bufSize]; + char* buf2 = new char[bufSize]; + char* buf3 = new char[bufSize]; + char* buf4 = new char[bufSize]; + char* buf5 = new char[bufSize]; + char* buf6 = new char[bufSize]; + + strlcpy(buf1, " 10\n", bufSize); + strlcpy(buf2, "10", bufSize); + strlcpy(buf3, "10\n", bufSize); + strlcpy(buf4, " 10 \n", bufSize); + strlcpy(buf5, " 10 \r", bufSize); + strlcpy(buf6, "\t10 \n", bufSize); // Try to avoid deleting array from an offset char* buf1Copy = buf1; diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index a2133034e..e65d6c104 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -233,7 +233,7 @@ void VPE::VPropertyFormWidget::commitData(int row) } else if (parent->propertyType() == Property::Complex) { - tmpProperty->UpdateParent(newValue); + parent->UpdateParent(newValue); emit propertyDataSubmitted(parent); } } diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index b9ccc0a57..8497ec0f0 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -67,7 +67,7 @@ void VAbstractOperation::GroupVisibility(quint32 object, bool visible) if (operatedObjects.contains(object)) { VAbstractSimple *obj = operatedObjects.value(object); - if (obj->GetType() == GOType::Point) + if (obj && obj->GetType() == GOType::Point) { VSimplePoint *item = qobject_cast(obj); SCASSERT(item != nullptr) @@ -392,7 +392,7 @@ void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId if (operatedObjects.contains(labelId)) { VAbstractSimple *obj = operatedObjects.value(labelId); - if (obj->GetType() == GOType::Point) + if (obj && obj->GetType() == GOType::Point) { VSimplePoint *item = qobject_cast(obj); SCASSERT(item != nullptr) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 4a4c77285..17bf93d9d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -210,7 +210,7 @@ QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc case 3: case 0: default: - return QPointF(); + break; } return QPointF(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index c2095e9b2..217e34c5f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -151,7 +151,7 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e } default: qDebug() << "Unxpected value" << res; - return QPointF(); + break; } return QPointF(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 5767cf5c3..2b372ba6a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -217,7 +217,7 @@ QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *ar case 3: case 0: default: - return QPointF(); + break; } return QPointF(); } diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 3e809144b..1e0dfbea4 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -131,7 +131,8 @@ void GraphicsViewZoom::VerticalScrollingTime(qreal x) // Try to adapt scrolling to speed of rotating mouse wheel and scale factor // Value of _numScheduledScrollings is too short, so we scale the value - qreal scroll = (qAbs(_numScheduledVerticalScrollings)*(10 + 10/_view->transform().m22()))/(duration/updateInterval); + qreal scroll = static_cast(qAbs(_numScheduledVerticalScrollings))*(10. + 10./_view->transform().m22()) + /(static_cast(duration)/static_cast(updateInterval)); if (qAbs(scroll) < 1) { @@ -152,8 +153,8 @@ void GraphicsViewZoom::HorizontalScrollingTime(qreal x) // Try to adapt scrolling to speed of rotating mouse wheel and scale factor // Value of _numScheduledScrollings is too short, so we scale the value - qreal scroll = (qAbs(_numScheduledHorizontalScrollings)*(10 + 10/_view->transform().m11()))/ - (duration/updateInterval); + qreal scroll = static_cast(qAbs(_numScheduledHorizontalScrollings))*(10. + 10./_view->transform().m11()) + /(static_cast(duration)/static_cast(updateInterval)); if (qAbs(scroll) < 1) { diff --git a/src/test/ValentinaTest/tst_vpiece.cpp b/src/test/ValentinaTest/tst_vpiece.cpp index 7668d80f0..cf5582aa8 100644 --- a/src/test/ValentinaTest/tst_vpiece.cpp +++ b/src/test/ValentinaTest/tst_vpiece.cpp @@ -49,7 +49,7 @@ void TST_VPiece::ClearLoop() // See file /src/app/share/collection/jacketМ6_30-110.val // Check correct seam allowance const Unit unit = Unit::Mm; - VContainer *data = new VContainer(nullptr, &unit); + QScopedPointer data(new VContainer(nullptr, &unit)); qApp->setPatternUnit(unit); data->UpdateGObject(304, new VPointF(61.866708661417327, 446.92270866141735, "Ф1", 5.0000125984251973, @@ -103,7 +103,7 @@ void TST_VPiece::ClearLoop() detail.GetPath()[0].SetFormulaSABefore("0"); detail.GetPath()[detail.GetPath().CountNodes()-1].SetFormulaSAAfter("0"); - const QVector pointsEkv = detail.SeamAllowancePoints(data); + const QVector pointsEkv = detail.SeamAllowancePoints(data.data()); QVector origPoints; origPoints.append(QPointF(42.46405659601932, 415.2845470563871)); @@ -152,7 +152,7 @@ void TST_VPiece::Issue620() // See file /src/app/share/collection/bugs/Issue_#620.vit // Check main path const Unit unit = Unit::Cm; - VContainer *data = new VContainer(nullptr, &unit); + QScopedPointer data(new VContainer(nullptr, &unit)); qApp->setPatternUnit(unit); data->UpdateGObject(1, new VPointF(30, 39.999874015748034, "A", 5.0000125984251973, 9.9999874015748045)); @@ -208,7 +208,7 @@ void TST_VPiece::Issue620() detail.GetPath().Append(VPieceNode(8, Tool::NodeSpline)); detail.GetPath().Append(VPieceNode(7, Tool::NodeSplinePath)); - const QVector pointsEkv = detail.MainPathPoints(data); + const QVector pointsEkv = detail.MainPathPoints(data.data()); QVector origPoints;