From 88f47ee72567f900a9e2a30751f45a2ae2543818 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 20 Nov 2018 12:37:32 -0200 Subject: [PATCH] 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 --- src/Mod/Arch/ArchPanel.py | 6 +++++- src/Mod/Arch/ArchWindow.py | 2 +- src/Mod/Draft/Draft.py | 15 +++++++++------ src/Mod/Draft/DraftGui.py | 3 +++ src/Mod/Draft/importSVG.py | 2 ++ src/Tools/offlinedoc/buildpdf.py | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Mod/Arch/ArchPanel.py b/src/Mod/Arch/ArchPanel.py index e1de3a594a..cd426a4ede 100644 --- a/src/Mod/Arch/ArchPanel.py +++ b/src/Mod/Arch/ArchPanel.py @@ -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"): diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index c4d9fd1bd9..674f0a48ad 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -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 diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 409b3969c8..23d3f53803 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -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]) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 6c3fa9600e..4515340f31 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -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 diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 69876464a8..e7506870db 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -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] diff --git a/src/Tools/offlinedoc/buildpdf.py b/src/Tools/offlinedoc/buildpdf.py index 825337d520..5caba4d075 100755 --- a/src/Tools/offlinedoc/buildpdf.py +++ b/src/Tools/offlinedoc/buildpdf.py @@ -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)