Fixed coverity issues

169009 Bad use of null-like value
169005 Bad use of null-like value
169003 Bad use of null-like value
169000 Bad use of null-like value
168998 Bad use of null-like value
168996 Structurally dead code
This commit is contained in:
Yorik van Havre
2018-11-20 12:37:32 -02:00
parent 11da78f582
commit 88f47ee725
6 changed files with 21 additions and 9 deletions

View File

@@ -448,6 +448,11 @@ class _Panel(ArchComponent.Component):
import Part #, DraftGeomUtils
layers = []
length = 0
width = 0
thickness = 0
# base tests
if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"):
@@ -473,7 +478,6 @@ class _Panel(ArchComponent.Component):
elif obj.Base.isDerivedFrom("Part::Feature"):
if not obj.Base.Shape.Solids:
return
layers = []
if hasattr(obj,"Material"):
if obj.Material:
if hasattr(obj.Material,"Materials"):

View File

@@ -1445,7 +1445,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
if 'DiffuseColor' in mat.Material:
if "(" in mat.Material['DiffuseColor']:
ccol = tuple([float(f) for f in mat.Material['DiffuseColor'].strip("()").split(",")])
if 'Transparency' in mat.Material:
if ccol and ('Transparency' in mat.Material):
ccol = (ccol[0],ccol[1],ccol[2],float(mat.Material['Transparency']))
if not ccol:
typeidx = (i*5)+1

View File

@@ -1769,12 +1769,15 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False):
else:
s1 = obj.Shape
s2 = newwire
w1 = s1.Edges
w2 = s2.Edges
w3 = Part.LineSegment(s1.Vertexes[0].Point,s2.Vertexes[0].Point).toShape()
w4 = Part.LineSegment(s1.Vertexes[-1].Point,s2.Vertexes[-1].Point).toShape()
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(Part.Wire(w1+[w3]+w2+[w4]))
if s1 and s2:
w1 = s1.Edges
w2 = s2.Edges
w3 = Part.LineSegment(s1.Vertexes[0].Point,s2.Vertexes[0].Point).toShape()
w4 = Part.LineSegment(s1.Vertexes[-1].Point,s2.Vertexes[-1].Point).toShape()
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(Part.Wire(w1+[w3]+w2+[w4]))
else:
print("Draft.offset: Unable to bind wires")
else:
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(obj.Shape.Wires[0])

View File

@@ -1817,6 +1817,9 @@ class DraftToolBar:
def getDefaultColor(self,type,rgb=False):
"gets color from the preferences or toolbar"
r = 0
g = 0
b = 0
if type == "snap":
color = Draft.getParam("snapcolor",4294967295)
r = ((color>>24)&0xFF)/255

View File

@@ -1118,6 +1118,8 @@ class svgHandler(xml.sax.ContentHandler):
sy = argsplit[1] if len(argsplit) > 1 else sx
m.scale(Vector(sx,sy,1))
elif transformation == 'rotate':
cx = 0
cy = 0
angle = argsplit[0]
if len(argsplit) >= 3:
cx = argsplit[1]

View File

@@ -437,7 +437,7 @@ def createpdf_firefox(pagename):
if (not exists(pagename+".pdf",image=True)) or OVERWRITE:
infile = FOLDER + os.sep + pagename+'.html'
outfile = FOLDER + os.sep + pagename+'.pdf'
return os.system('firefox -print ' + infile)
os.system('firefox -print ' + infile)
time.sleep(6)
if os.path.exists(FIREFOXPDFFOLDER + os.sep + pagename + ".pdf"):
shutil.move(FIREFOXPDFFOLDER+os.sep+pagename+".pdf",outfile)