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 "vtoolpoint.h"
#include <QKeyEvent> #include <QKeyEvent>
#include <QLoggingCategory>
#include "../../geometry/vpointf.h" #include "../../geometry/vpointf.h"
#include "../../visualization/vgraphicssimpletextitem.h" #include "../../visualization/vgraphicssimpletextitem.h"
#include "../../undocommands/movelabel.h" #include "../../undocommands/movelabel.h"
Q_LOGGING_CATEGORY(vToolPoint, "v.toolPoint")
const QString VToolPoint::TagName = QStringLiteral("point"); const QString VToolPoint::TagName = QStringLiteral("point");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -79,12 +82,21 @@ void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VToolPoint::name() const 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) void VToolPoint::setName(const QString &name)
{ {
// Don't know if need check name here.
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
obj->setName(name); obj->setName(name);
SaveOption(obj); SaveOption(obj);

View File

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

View File

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