Fixed "comparing floating point with == is unsafe"
--HG-- branch : feature
This commit is contained in:
parent
55ab727d78
commit
0b16f5acf0
|
@ -34,4 +34,20 @@ enum class VarMeasurement : unsigned char { English=0, Metric=1 };
|
|||
//Default drawing units for AutoCAD DesignCenter blocks:
|
||||
enum class VarInsunits : unsigned char { Inches=1, Millimeters=4, Centimeters=5 };
|
||||
|
||||
static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2)
|
||||
{
|
||||
if(qFuzzyIsNull(p1))
|
||||
{
|
||||
return qFuzzyIsNull(p2);
|
||||
}
|
||||
else if(qFuzzyIsNull(p2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return qFuzzyCompare(p1, p2);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DXFDEF_H
|
||||
|
|
|
@ -3089,13 +3089,13 @@ void DL_Dxf::writeInsert(DL_WriterA& dw,
|
|||
dw.dxfReal(10, data.ipx);
|
||||
dw.dxfReal(20, data.ipy);
|
||||
dw.dxfReal(30, data.ipz);
|
||||
if (data.sx!=1.0 || data.sy!=1.0)
|
||||
if (!DL_FuzzyComparePossibleNulls(data.sx, 1.0) || !DL_FuzzyComparePossibleNulls(data.sy, 1.0))
|
||||
{
|
||||
dw.dxfReal(41, data.sx);
|
||||
dw.dxfReal(42, data.sy);
|
||||
dw.dxfReal(43, 1.0);
|
||||
}
|
||||
if (data.angle!=0.0)
|
||||
if (!DL_FuzzyComparePossibleNulls(data.angle, 0.0))
|
||||
{
|
||||
dw.dxfReal(50, data.angle);
|
||||
}
|
||||
|
@ -3104,7 +3104,7 @@ void DL_Dxf::writeInsert(DL_WriterA& dw,
|
|||
dw.dxfInt(70, data.cols);
|
||||
dw.dxfInt(71, data.rows);
|
||||
}
|
||||
if (data.colSp!=0.0 || data.rowSp!=0.0)
|
||||
if (!DL_FuzzyComparePossibleNulls(data.colSp, 0.0) || !DL_FuzzyComparePossibleNulls(data.rowSp, 0.0))
|
||||
{
|
||||
dw.dxfReal(44, data.colSp);
|
||||
dw.dxfReal(45, data.rowSp);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define DL_ENTITIES_H
|
||||
|
||||
#include "dl_global.h"
|
||||
#include "dxfdef.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -168,9 +169,9 @@ struct DXFLIB_EXPORT DL_StyleData
|
|||
// ignore lastHeightUsed:
|
||||
return (name==other.name &&
|
||||
flags==other.flags &&
|
||||
fixedTextHeight==other.fixedTextHeight &&
|
||||
widthFactor==other.widthFactor &&
|
||||
obliqueAngle==other.obliqueAngle &&
|
||||
DL_FuzzyComparePossibleNulls(fixedTextHeight, other.fixedTextHeight) &&
|
||||
DL_FuzzyComparePossibleNulls(widthFactor, other.widthFactor) &&
|
||||
DL_FuzzyComparePossibleNulls(obliqueAngle, other.obliqueAngle) &&
|
||||
textGenerationFlags==other.textGenerationFlags &&
|
||||
primaryFontFile==other.primaryFontFile &&
|
||||
bigFontFile==other.bigFontFile);
|
||||
|
|
Loading…
Reference in New Issue
Block a user