Coverity Scan.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-02 21:20:09 +02:00
parent 850d51adac
commit 8b0de7504f
3 changed files with 30 additions and 23 deletions

View file

@ -28,10 +28,13 @@
#include "vtoolpoint.h"
#include <QKeyEvent>
#include <QLoggingCategory>
#include "../../geometry/vpointf.h"
#include "../../visualization/vgraphicssimpletextitem.h"
#include "../../undocommands/movelabel.h"
Q_LOGGING_CATEGORY(vToolPoint, "v.toolPoint")
const QString VToolPoint::TagName = QStringLiteral("point");
//---------------------------------------------------------------------------------------------------------------------
@ -79,12 +82,21 @@ void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
//---------------------------------------------------------------------------------------------------------------------
QString VToolPoint::name() const
{
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
try
{
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
}
catch (const VExceptionBadId &e)
{
qCDebug(vToolPoint)<<"Error!"<<"Couldn't get point name."<<e.ErrorMessage()<<e.DetailedInformation();
return QString("");// Return empty string for property browser
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::setName(const QString &name)
{
// Don't know if need check name here.
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
obj->setName(name);
SaveOption(obj);

View file

@ -239,15 +239,8 @@ QLineF VContour::GlobalEdge(int i) const
return QLineF();
}
if (n <= 0)
{
return axis;
}
else
{
const qreal nShift = axis.length()/n;
return QLineF(nShift*(i-1), 0, nShift*i, 0);
}
const qreal nShift = axis.length()/n;
return QLineF(nShift*(i-1), 0, nShift*i, 0);
}
else
{

View file

@ -580,22 +580,24 @@ QVector<QPointF> VPosition::CutEdge(const QLineF &edge, unsigned int shift)
points.append(edge.p1());
points.append(edge.p2());
}
const int n = qFloor(edge.length()/shift);
if (n <= 0)
{
points.append(edge.p1());
points.append(edge.p2());
}
else
{
const qreal nShift = edge.length()/n;
for (int i = 1; i <= n+1; ++i)
const int n = qFloor(edge.length()/shift);
if (n <= 0)
{
QLineF l1 = edge;
l1.setLength(nShift*(i-1));
points.append(l1.p2());
points.append(edge.p1());
points.append(edge.p2());
}
else
{
const qreal nShift = edge.length()/n;
for (int i = 1; i <= n+1; ++i)
{
QLineF l1 = edge;
l1.setLength(nShift*(i-1));
points.append(l1.p2());
}
}
}
return points;