From 9424395afc95694c2934591163a0a233e522c2e4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jul 2020 14:26:29 +0200 Subject: [PATCH] PVS: V1004 A pointer was used unsafely after it was verified against nullptr --- src/App/DocumentObject.cpp | 2 +- src/Gui/DlgObjectSelection.cpp | 1 - src/Gui/ViewProviderPyImp.cpp | 4 ++-- src/Mod/Part/Gui/TaskDimension.cpp | 6 ++++-- src/Mod/TechDraw/App/DrawViewPart.cpp | 1 + src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 11 ++++++----- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 262633cc00..0b5975f330 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -699,7 +699,7 @@ void DocumentObject::onChanged(const Property* prop) return; if(!GetApplication().isRestoring() && - prop && !prop->testStatus(Property::PartialTrigger) && + !prop->testStatus(Property::PartialTrigger) && getDocument() && getDocument()->testStatus(Document::PartialDoc)) { diff --git a/src/Gui/DlgObjectSelection.cpp b/src/Gui/DlgObjectSelection.cpp index e8ada443da..127aeef5e7 100644 --- a/src/Gui/DlgObjectSelection.cpp +++ b/src/Gui/DlgObjectSelection.cpp @@ -73,7 +73,6 @@ DlgObjectSelection::DlgObjectSelection( info.depItem = new QTreeWidgetItem(ui->depList); auto vp = Gui::Application::Instance->getViewProvider(obj); if(vp) info.depItem->setIcon(0, vp->getIcon()); - info.depItem->setIcon(0, vp->getIcon()); info.depItem->setText(0, QString::fromUtf8((obj)->Label.getValue())); info.depItem->setText(1, QString::fromUtf8(obj->getDocument()->getName())); info.depItem->setText(2, QString::fromLatin1(obj->getNameInDocument())); diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 2d0bd4c837..a81c905e5e 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -414,11 +414,11 @@ PyObject* ViewProviderPy::partialRender(PyObject* args) #endif else { std::string error = std::string("type must be str or unicode"); - if(item) { + if (item) { error += " not, "; error += item->ob_type->tp_name; } - throw Base::TypeError(error + item->ob_type->tp_name); + throw Base::TypeError(error); } } } diff --git a/src/Mod/Part/Gui/TaskDimension.cpp b/src/Mod/Part/Gui/TaskDimension.cpp index 290403cd64..1447796a93 100644 --- a/src/Mod/Part/Gui/TaskDimension.cpp +++ b/src/Mod/Part/Gui/TaskDimension.cpp @@ -1236,8 +1236,10 @@ void PartGui::DimensionAngular::setupDimension() //text SoSeparator *textSep = static_cast(getPart("textSep", true)); - if (textSep) - textSep->addChild(material); + if (!textSep) + return; + + textSep->addChild(material); SoCalculator *textVecCalc = new SoCalculator(); textVecCalc->a.connectFrom(&angle); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 08dc544e0d..13972c9fcf 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -1195,6 +1195,7 @@ int DrawViewPart::add1CVToGV(std::string tag) TechDraw::CosmeticVertex* cv = getCosmeticVertex(tag); if (cv == nullptr) { Base::Console().Message("DVP::add1CVToGV 2 - cv %s not found\n", tag.c_str()); + return 0; } int iGV = geometryObject->addCosmeticVertex(cv->scaled(getScale()), cv->getTagAsString()); diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index bcc9cebc9a..a23d30fa62 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -154,11 +154,12 @@ void TaskProjGroup::saveGroupState() m_saveSpacingY = multiView->spacingY.getValue(); DrawProjGroupItem* anchor = multiView->getAnchor(); m_saveDirection = anchor->Direction.getValue(); - } - for( const auto it : multiView->Views.getValues() ) { - auto view( dynamic_cast(it) ); - if (view != nullptr) { - m_saveViewNames.push_back(view->Type.getValueAsString()); + + for( const auto it : multiView->Views.getValues() ) { + auto view( dynamic_cast(it) ); + if (view != nullptr) { + m_saveViewNames.push_back(view->Type.getValueAsString()); + } } } }