diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index c6aadd936e..aa1112b9c9 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -1463,31 +1463,36 @@ std::string ObjectIdentifier::String::toString(bool toPython) const void ObjectIdentifier::String::checkImport(const App::DocumentObject *owner, const App::DocumentObject *obj, String *objName) { - if(owner && owner->getDocument() && - str.size() && - ExpressionParser::ExpressionImporter::reader()) - { + if(owner && owner->getDocument() && str.size() && + ExpressionParser::ExpressionImporter::reader()) { auto reader = ExpressionParser::ExpressionImporter::reader(); - if(obj || objName) { + if (obj || objName) { bool restoreLabel = false; str = PropertyLinkBase::importSubName(*reader,str.c_str(),restoreLabel); - if(restoreLabel) { - if(!obj) { + if (restoreLabel) { + if (!obj) { std::bitset<32> flags; obj = getDocumentObject(owner->getDocument(),*objName,flags); - if(!obj) + if (!obj) { FC_ERR("Cannot find object " << objName->toString()); + } + } + + if (obj) { + PropertyLinkBase::restoreLabelReference(obj,str); } - PropertyLinkBase::restoreLabelReference(obj,str); } - } else if (str.back()!='@') + } + else if (str.back()!='@') { str = reader->getName(str.c_str()); - else{ + } + else { str.resize(str.size()-1); auto mapped = reader->getName(str.c_str()); auto obj = owner->getDocument()->getObject(mapped); - if(!obj) + if (!obj) { FC_ERR("Cannot find object " << str); + } else { isString = true; forceIdentifier = false; diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 8cfd137085..5b2005bb71 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -613,7 +613,7 @@ void PropertyLinkList::setSize(int newSize) { for(int i=newSize;i<(int)_lValueList.size();++i) { auto obj = _lValueList[i]; - if(!obj && !obj->getNameInDocument()) + if (!obj || !obj->getNameInDocument()) continue; _nameMap.erase(obj->getNameInDocument()); #ifndef USE_OLD_DAG diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 32737ce39c..29e0c291a7 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -576,13 +576,14 @@ App::DocumentObject* FemVTKTools::readResult(const char* filename, App::Document vtkSmartPointer dataset = ds; App::DocumentObject* result = NULL; - if(!res) - result = res; - else + + if (res) { Base::Console().Message("FemResultObject pointer is NULL, trying to get the active object\n"); if(obj->getTypeId() == Base::Type::fromName("Fem::FemResultObjectPython")) + { result = obj; + } else { Base::Console().Message("the active object is not the correct type, do nothing\n"); @@ -594,11 +595,17 @@ App::DocumentObject* FemVTKTools::readResult(const char* filename, App::Document std::unique_ptr fmesh(new FemMesh()); importVTKMesh(dataset, fmesh.get()); static_cast(mesh->getPropertyByName("FemMesh"))->setValuePtr(fmesh.release()); - static_cast(result->getPropertyByName("Mesh"))->setValue(mesh); - // PropertyLink is the property type to store DocumentObject pointer - //vtkSmartPointer pd = dataset->GetPointData(); - importFreeCADResult(dataset, result); + if (result) + { + // PropertyLink is the property type to store DocumentObject pointer + App::PropertyLink* link = dynamic_cast(result->getPropertyByName("Mesh")); + if (link) + link->setValue(mesh); + + //vtkSmartPointer pd = dataset->GetPointData(); + importFreeCADResult(dataset, result); + } pcDoc->recompute(); Base::Console().Log(" %f: Done \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); @@ -866,6 +873,7 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar field = static_cast(res->getPropertyByName(it->first.c_str())); else Base::Console().Error("PropertyFloatList %s not found \n", it->first.c_str()); + if (field && field->getSize() > 0) { //if (nPoints != field->getSize()) // Base::Console().Error("Size of PropertyFloatList = %d, not equal to vtk mesh node count %d \n", field->getSize(), nPoints); @@ -890,9 +898,10 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar grid->GetPointData()->AddArray(data); Base::Console().Log(" The PropertyFloatList %s was exported to VTK scalar list: %s\n", it->first.c_str(), it->second.c_str()); - } - else + } + else if (field) { Base::Console().Log(" PropertyFloatList NOT exported to vtk: %s size is: %i\n", it->first.c_str(), field->getSize()); + } } Base::Console().Log("End: Create VTK result data from FreeCAD result data.\n"); diff --git a/src/Mod/Import/App/ImportOCAF2.cpp b/src/Mod/Import/App/ImportOCAF2.cpp index 2478ba9c09..f5428ad38b 100644 --- a/src/Mod/Import/App/ImportOCAF2.cpp +++ b/src/Mod/Import/App/ImportOCAF2.cpp @@ -1129,7 +1129,8 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj, App::DocumentObject *obj; auto shape = Part::Feature::getTopoShape(parentObj,sub,false,0,&obj,false,!sub); if(!obj || shape.isNull()) { - FC_WARN(obj->getFullName() << " has null shape"); + if (obj) + FC_WARN(obj->getFullName() << " has null shape"); return TDF_Label(); } diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index aa407ac12a..835c794fe8 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -2210,16 +2210,18 @@ private: if (!PyArg_ParseTuple(args.ptr(), "sss",&sub,&mapped,&element)) throw Py::Exception(); std::string subname(sub); - if(subname.size() && subname[subname.size()-1]!='.') + if (subname.size() && subname[subname.size()-1]!='.') subname += '.'; - if(mapped && mapped[0]) { - if(!Data::ComplexGeoData::isMappedElement(mapped)) + if (mapped && mapped[0]) { + if (!Data::ComplexGeoData::isMappedElement(mapped)) subname += Data::ComplexGeoData::elementMapPrefix(); subname += mapped; - if(element && element[0] && subname[subname.size()-1]!='.') - subname += '.'; } - subname += element; + if (element && element[0]) { + if (subname.size() && subname[subname.size()-1]!='.') + subname += '.'; + subname += element; + } return Py::String(subname); } }; diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 709873bc3d..70e3548aeb 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -929,11 +929,10 @@ void ViewProviderPartExt::reload() void ViewProviderPartExt::updateData(const App::Property* prop) { - const char *propName = prop?prop->getName():""; - if(propName && (strcmp(propName,"Shape")==0 || strstr(propName,"Touched")!=0)) - { + const char *propName = prop->getName(); + if (propName && (strcmp(propName, "Shape") == 0 || strstr(propName, "Touched") != nullptr)) { // calculate the visual only if visible - if (isUpdateForced()||Visibility.getValue()) + if (isUpdateForced() || Visibility.getValue()) updateVisual(); else VisualTouched = true; diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp index c12056799c..1255661ef8 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp @@ -407,7 +407,7 @@ void SheetView::currentChanged ( const QModelIndex & current, const QModelIndex void SheetView::updateCell(const App::Property *prop) { try { - if (sheet && prop == &sheet->Label) { + if (prop == &sheet->Label) { QString cap = QString::fromUtf8(sheet->Label.getValue()); setWindowTitle(cap); } diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp index 64802b0994..e9754da795 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp @@ -366,7 +366,7 @@ void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloon) DrawView* balloonParent = nullptr; double scale = 1.0; App::DocumentObject* docObj = balloon->SourceView.getValue(); - if (docObj == nullptr) { + if (docObj) { balloonParent = dynamic_cast(docObj); if (balloonParent) scale = balloonParent->getScale(); diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 9f97bd3ae7..182bdf80d3 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -97,8 +97,10 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat, if (m_cl == nullptr) { //checked by CommandAnnotate. Should never happen. Base::Console().Message("TCL::TCL() - no centerline found\n"); } - m_type = m_cl->m_type; - m_mode = m_cl->m_mode; + else { + m_type = m_cl->m_type; + m_mode = m_cl->m_mode; + } setUiEdit(); } diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index b7a68669c7..a9bcdc2df7 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -95,6 +95,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat): m_basePage = m_baseFeat->findParentPage(); if (m_basePage == nullptr) { Base::Console().Error("TaskDetail - bad parameters - base page. Can not proceed.\n"); + return; } m_baseName = m_baseFeat->getNameInDocument(); diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index 6f63cb7873..a4b8739a80 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -421,7 +421,9 @@ void TaskLeaderLine::createLeaderFeature(std::vector converted) if (m_basePage != nullptr) { m_basePage->touch(); } - m_lineFeat->requestPaint(); + if (m_lineFeat != nullptr) { + m_lineFeat->requestPaint(); + } } void TaskLeaderLine::updateLeaderFeature(void)