Coverity: Dereference null return value

This commit is contained in:
wmayer
2020-07-19 16:21:20 +02:00
parent fdd6d341c7
commit ba683bf241
4 changed files with 23 additions and 13 deletions

View File

@@ -1823,8 +1823,8 @@ void TreeWidget::dropEvent(QDropEvent *event)
std::string dropName;
ss.str("");
if(da == Qt::LinkAction) {
if(targetItemObj->getParentItem()) {
auto parentItem = targetItemObj->getParentItem();
auto parentItem = targetItemObj->getParentItem();
if (parentItem) {
ss << Command::getObjectCmd(
parentItem->object()->getObject(),0,".replaceObject(",true)
<< Command::getObjectCmd(targetObj) << ","

View File

@@ -205,17 +205,19 @@ void TaskDressUpParameters::setSelection(QListWidgetItem* current) {
std::string docName = DressUpView->getObject()->getDocument()->getName();
// get the name of the body we are in
Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject());
std::string objName = body->getNameInDocument();
if (body) {
std::string objName = body->getNameInDocument();
// hide fillet to see the original edge
// (a fillet creates new edges so that the original one is not available)
hideObject();
// highlight all objects in the list
DressUpView->highlightReferences(true);
// clear existing selection because only the current item is highlighted, not all selected ones to keep the overview
Gui::Selection().clearSelection();
// highligh the selected item
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
// hide fillet to see the original edge
// (a fillet creates new edges so that the original one is not available)
hideObject();
// highlight all objects in the list
DressUpView->highlightReferences(true);
// clear existing selection because only the current item is highlighted, not all selected ones to keep the overview
Gui::Selection().clearSelection();
// highligh the selected item
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
}
}
}

View File

@@ -659,6 +659,9 @@ PyObject* DrawViewPartPy::getEdgeByIndex(PyObject *args)
//this is scaled and +Yup
//need unscaled and +Ydown
TechDraw::BaseGeom* geom = dvp->getGeomByIndex(edgeIndex);
if (geom == nullptr) {
throw Py::ValueError("wrong edgeIndex");
}
TopoDS_Shape temp = TechDraw::mirrorShapeVec(geom->occEdge,
Base::Vector3d(0.0, 0.0, 0.0),
@@ -679,6 +682,9 @@ PyObject* DrawViewPartPy::getVertexByIndex(PyObject *args)
//this is scaled and +Yup
//need unscaled and +Ydown
TechDraw::Vertex* vert = dvp->getProjVertexByIndex(vertexIndex);
if (vert == nullptr) {
throw Py::ValueError("wrong vertIndex");
}
Base::Vector3d point = DrawUtil::invertY(vert->point()) / dvp->getScale();
gp_Pnt gPoint(point.x, point.y, point.z);

View File

@@ -389,7 +389,9 @@ void TaskRichAnno::createAnnoFeature()
if (m_basePage != nullptr) {
m_basePage->touch();
}
m_annoFeat->requestPaint();
if (m_annoFeat != nullptr) {
m_annoFeat->requestPaint();
}
}
void TaskRichAnno::updateAnnoFeature()