[PD] remove more superfluous nullptr checks
This commit is contained in:
@@ -118,7 +118,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
// Pull direction
|
||||
gp_Dir pullDirection;
|
||||
App::DocumentObject* refDirection = PullDirection.getValue();
|
||||
if (refDirection != nullptr) {
|
||||
if (refDirection) {
|
||||
if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
PartDesign::Line* line = static_cast<PartDesign::Line*>(refDirection);
|
||||
Base::Vector3d d = line->getDirection();
|
||||
@@ -229,7 +229,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
|
||||
neutralPlane = adapt.Plane();
|
||||
} else if (ref.ShapeType() == TopAbs_EDGE) {
|
||||
if (refDirection != nullptr) {
|
||||
if (refDirection) {
|
||||
// Create neutral plane through edge normal to pull direction
|
||||
TopoDS_Edge refEdge = TopoDS::Edge(ref);
|
||||
if (refEdge.IsNull())
|
||||
|
||||
@@ -410,7 +410,7 @@ void ProfileBased::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &Profile) {
|
||||
// if attached to a sketch then mark it as read-only
|
||||
this->Placement.setStatus(App::Property::ReadOnly, Profile.getValue() != nullptr);
|
||||
this->Placement.setStatus(App::Property::ReadOnly, Profile.getValue());
|
||||
}
|
||||
|
||||
FeatureAddSub::onChanged(prop);
|
||||
|
||||
@@ -2558,7 +2558,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
||||
prevFeature = pcActiveBody->getPrevSolidFeature(trFeat);
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
if (prevFeature != nullptr)
|
||||
if (prevFeature)
|
||||
Gui::Selection().addSelection(prevFeature->getDocument()->getName(), prevFeature->getNameInDocument());
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Convert to MultiTransform feature"));
|
||||
@@ -2608,7 +2608,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
||||
|
||||
// Make sure the user isn't presented with an empty screen because no transformations are defined yet...
|
||||
App::DocumentObject* prevSolid = pcActiveBody->Tip.getValue();
|
||||
if (prevSolid != nullptr) {
|
||||
if (prevSolid) {
|
||||
Part::Feature* feat = static_cast<Part::Feature*>(prevSolid);
|
||||
FCMD_OBJ_CMD(Feat,"Shape = "<<getObjectCmd(feat)<<".Shape");
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void CmdPartDesignBody::activated(int iMsg)
|
||||
}
|
||||
else {
|
||||
partOfBaseFeature = App::Part::getPartOfObject(baseFeature);
|
||||
if (partOfBaseFeature != nullptr && partOfBaseFeature != actPart){
|
||||
if (partOfBaseFeature && partOfBaseFeature != actPart){
|
||||
//prevent cross-part mess
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
|
||||
QObject::tr("Base feature (%1) belongs to other part.")
|
||||
|
||||
@@ -139,18 +139,18 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
// Hide base body and added body
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue()));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->hide();
|
||||
vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(bodies.front()));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->hide();
|
||||
BooleanView->show();
|
||||
} else {
|
||||
// Hide newly added body
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(bodies.back()));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->hide();
|
||||
}
|
||||
}
|
||||
@@ -179,12 +179,12 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
// Make bodies visible again
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(pcBody));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->show();
|
||||
if (bodies.size() == 0) {
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue()));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->show();
|
||||
BooleanView->hide();
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void TaskBooleanParameters::onButtonBodyRemove(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc != nullptr)
|
||||
if (doc)
|
||||
BooleanView->show();
|
||||
selectionMode = bodyRemove;
|
||||
Gui::Selection().clearSelection();
|
||||
@@ -273,12 +273,12 @@ void TaskBooleanParameters::onBodyDeleted(void)
|
||||
// Make bodies visible again
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(body));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->show();
|
||||
if (bodies.empty()) {
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(pcBoolean->BaseFeature.getValue()));
|
||||
if (vp != nullptr)
|
||||
if (vp)
|
||||
vp->show();
|
||||
BooleanView->hide();
|
||||
}
|
||||
@@ -303,7 +303,7 @@ void TaskBooleanParameters::exitSelectionMode()
|
||||
{
|
||||
selectionMode = none;
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc != nullptr)
|
||||
if (doc)
|
||||
doc->setShow(BooleanView->getObject()->getNameInDocument());
|
||||
}
|
||||
|
||||
@@ -378,8 +378,8 @@ bool TaskDlgBooleanParameters::reject()
|
||||
// Show the bodies again
|
||||
PartDesign::Boolean* obj = static_cast<PartDesign::Boolean*>(BooleanView->getObject());
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc != nullptr) {
|
||||
if (obj->BaseFeature.getValue() != nullptr) {
|
||||
if (doc) {
|
||||
if (obj->BaseFeature.getValue()) {
|
||||
doc->setShow(obj->BaseFeature.getValue()->getNameInDocument());
|
||||
std::vector<App::DocumentObject*> bodies = obj->Group.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++)
|
||||
|
||||
@@ -141,7 +141,7 @@ void TaskLinearPatternParameters::setupUI()
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
if (obj != nullptr) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument()));
|
||||
|
||||
@@ -122,7 +122,7 @@ void TaskMirroredParameters::setupUI()
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
if (obj != nullptr) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument()));
|
||||
|
||||
@@ -148,7 +148,7 @@ void TaskPolarPatternParameters::setupUI()
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
if (obj != nullptr) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument()));
|
||||
|
||||
@@ -113,7 +113,7 @@ void TaskScaledParameters::setupUI()
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
if (obj != nullptr) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1(obj->getNameInDocument()));
|
||||
|
||||
@@ -248,7 +248,7 @@ bool ViewProvider::onDelete(const std::vector<std::string> &)
|
||||
// find surrounding features in the tree
|
||||
Part::BodyBase* body = PartDesign::Body::findBodyOf(getObject());
|
||||
|
||||
if (body != nullptr) {
|
||||
if (body) {
|
||||
// Deletion from the tree of a feature is handled by Document.removeObject, which has no clue
|
||||
// about what a body is. Therefore, Bodies, although an "activable" container, know nothing
|
||||
// about what happens at Document level with the features they contain.
|
||||
|
||||
@@ -477,7 +477,7 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const
|
||||
|
||||
App::Part *actPart = PartDesignGui::getActivePart();
|
||||
App::Part* partOfBaseFeature = App::Part::getPartOfObject(obj);
|
||||
if (partOfBaseFeature != nullptr && partOfBaseFeature != actPart)
|
||||
if (partOfBaseFeature && partOfBaseFeature != actPart)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -289,7 +289,7 @@ bool ViewProviderDatum::doubleClicked(void)
|
||||
PartDesign::Body* activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
auto datumBody = PartDesignGui::getBodyFor(pcDatum, false);
|
||||
|
||||
if (datumBody != nullptr) {
|
||||
if (datumBody) {
|
||||
if (datumBody != activeBody) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.ActiveDocument.ActiveView.setActiveObject('%s',%s)",
|
||||
|
||||
@@ -93,7 +93,7 @@ void ViewProviderHelix::unsetEdit(int ModNum)
|
||||
std::vector<App::DocumentObject*> ViewProviderHelix::claimChildren(void) const {
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
App::DocumentObject* sketch = static_cast<PartDesign::ProfileBased*>(getObject())->Profile.getValue();
|
||||
if (sketch != nullptr && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (sketch && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(sketch);
|
||||
|
||||
return temp;
|
||||
|
||||
@@ -54,11 +54,11 @@ std::vector<App::DocumentObject*> ViewProviderLoft::claimChildren(void)const
|
||||
PartDesign::Loft* pcLoft = static_cast<PartDesign::Loft*>(getObject());
|
||||
|
||||
App::DocumentObject* sketch = pcLoft->getVerifiedSketch(true);
|
||||
if (sketch != nullptr)
|
||||
if (sketch)
|
||||
temp.push_back(sketch);
|
||||
|
||||
for(App::DocumentObject* obj : pcLoft->Sections.getValues()) {
|
||||
if (obj != nullptr && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (obj && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,20 +54,20 @@ std::vector<App::DocumentObject*> ViewProviderPipe::claimChildren(void)const
|
||||
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getObject());
|
||||
|
||||
App::DocumentObject* sketch = pcPipe->getVerifiedSketch(true);
|
||||
if (sketch != nullptr)
|
||||
if (sketch)
|
||||
temp.push_back(sketch);
|
||||
|
||||
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
|
||||
if (obj != nullptr && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (obj && obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(obj);
|
||||
}
|
||||
|
||||
App::DocumentObject* spine = pcPipe->Spine.getValue();
|
||||
if (spine != nullptr && spine->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (spine && spine->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(spine);
|
||||
|
||||
App::DocumentObject* auxspine = pcPipe->AuxillerySpine.getValue();
|
||||
if (auxspine != nullptr && auxspine->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (auxspine && auxspine->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(auxspine);
|
||||
|
||||
return temp;
|
||||
|
||||
@@ -48,7 +48,7 @@ ViewProviderSketchBased::~ViewProviderSketchBased()
|
||||
std::vector<App::DocumentObject*> ViewProviderSketchBased::claimChildren(void) const {
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
App::DocumentObject* sketch = static_cast<PartDesign::ProfileBased*>(getObject())->Profile.getValue();
|
||||
if (sketch != nullptr && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
if (sketch && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(sketch);
|
||||
|
||||
return temp;
|
||||
|
||||
@@ -200,7 +200,7 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con
|
||||
|
||||
if ( docHaveBodies ) {
|
||||
bool addMoveFeature = true;
|
||||
bool addMoveFeatureInTree = (body != nullptr);
|
||||
bool addMoveFeatureInTree = body;
|
||||
for (auto sel: selection) {
|
||||
// if at least one selected feature cannot be moved to a body
|
||||
// disable the entry
|
||||
|
||||
Reference in New Issue
Block a user