From 8304a0942e4e361b705611ac763b535430d6b2ef Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 20 Jul 2022 02:32:52 +0200 Subject: [PATCH] [TD] remove more superfluous nullptr checks --- src/Mod/TechDraw/App/AppTechDrawPy.cpp | 4 +- src/Mod/TechDraw/App/Cosmetic.cpp | 2 +- src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp | 2 +- src/Mod/TechDraw/App/DrawViewSection.cpp | 2 +- src/Mod/TechDraw/App/GeometryObject.cpp | 2 +- src/Mod/TechDraw/App/LandmarkDimension.cpp | 2 +- src/Mod/TechDraw/App/ShapeExtractor.cpp | 2 +- src/Mod/TechDraw/Gui/Command.cpp | 4 +- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 52 +++++++++---------- src/Mod/TechDraw/Gui/CommandDecorate.cpp | 6 +-- src/Mod/TechDraw/Gui/CommandExtensionDims.cpp | 2 +- src/Mod/TechDraw/Gui/CommandExtensionPack.cpp | 16 +++--- src/Mod/TechDraw/Gui/Grabber3d.cpp | 6 +-- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 36 +++++++------ src/Mod/TechDraw/Gui/QGEPath.cpp | 6 +-- src/Mod/TechDraw/Gui/QGILeaderLine.cpp | 10 ++-- src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 16 +++--- src/Mod/TechDraw/Gui/QGIProjGroup.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderPage.cpp | 4 +- 19 files changed, 89 insertions(+), 87 deletions(-) diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 2901d933f4..b67450374c 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -710,7 +710,7 @@ private: } else if (v->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) { DrawViewDimension* dvd = static_cast(v); TechDraw::DrawViewPart* dvp = dvd->getViewPart(); - if (dvp == nullptr) { + if (!dvp) { continue; } double grandParentX = 0.0; @@ -718,7 +718,7 @@ private: if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { TechDraw::DrawProjGroupItem* dpgi = static_cast(dvp); TechDraw::DrawProjGroup* dpg = dpgi->getPGroup(); - if (dpg == nullptr) { + if (!dpg) { continue; } grandParentX = dpg->X.getValue(); diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index e18be8603a..e0e54d872d 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -1254,7 +1254,7 @@ void CenterLine::Save(Base::Writer &writer) const writer.Stream() << writer.ind() << "" << endl; //stored geometry - if (m_geometry == nullptr) { + if (!m_geometry) { return Base::Console().Error("CL::Save - m_geometry is null\n"); } diff --git a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp index 30a9eb987d..c1d1fc68ba 100644 --- a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp +++ b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp @@ -363,7 +363,7 @@ void CosmeticEdgePy::setCenter(Py::Object arg) pNew = DrawUtil::invertY(pNew); auto oldGeom = getCosmeticEdgePtr()->m_geometry; TechDraw::CirclePtr oldCircle = std::dynamic_pointer_cast (oldGeom); - if (oldCircle == nullptr) { + if (!oldCircle) { throw Py::TypeError("Edge geometry is not a circle"); } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index a73551cd5d..8975135c0b 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -289,7 +289,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) } App::DocumentObject* base = BaseView.getValue(); - if (base == nullptr) { + if (!base) { return new App::DocumentObjectExecReturn("BaseView object not found"); } diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 645edc2368..c016e558bc 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -494,7 +494,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca } base = BaseGeom::baseFactory(edge); - if (base == nullptr) { + if (!base) { Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n",i); continue; // throw Base::ValueError("GeometryObject::addGeomFromCompound - baseFactory failed"); diff --git a/src/Mod/TechDraw/App/LandmarkDimension.cpp b/src/Mod/TechDraw/App/LandmarkDimension.cpp index 3496260eae..7dfb3ec7ca 100644 --- a/src/Mod/TechDraw/App/LandmarkDimension.cpp +++ b/src/Mod/TechDraw/App/LandmarkDimension.cpp @@ -108,7 +108,7 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute(void) } DrawViewPart* dvp = getViewPart(); - if (dvp == nullptr) { + if (!dvp) { return App::DocumentObject::StdReturn; } References2D.setValue(dvp); diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index 023d46d3d4..f2b0bd91c5 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -161,7 +161,7 @@ std::vector ShapeExtractor::getXShapes(const App::Link* xLink) { // Base::Console().Message("SE::getXShapes(%X) - %s\n", xLink, xLink->getNameInDocument()); std::vector xSourceShapes; - if (xLink == nullptr) { + if (!xLink) { return xSourceShapes; } diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 6e48533cdb..944573eb3f 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -876,7 +876,7 @@ void CmdTechDrawBalloon::activated(int iMsg) std::vector selection = getSelection().getSelectionEx(); auto objFeat(dynamic_cast(selection[0].getObject())); - if (objFeat == nullptr) { + if (!objFeat) { return; } @@ -1266,7 +1266,7 @@ void CmdTechDrawArchView::activated(int iMsg) return; } - if (archObject == nullptr) { + if (!archObject) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("No Arch Sections in selection.")); return; diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index d548dc3bf2..89c4ceffb1 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -517,7 +517,7 @@ void CmdTechDrawQuadrants::activated(int iMsg) { Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -596,7 +596,7 @@ void CmdTechDrawCenterLineGroup::activated(int iMsg) { // Base::Console().Message("CMD::CenterLineGroup - activated(%d)\n", iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -700,7 +700,7 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -724,18 +724,19 @@ void execCenterLine(Gui::Command* cmd) } std::vector selection = cmd->getSelection().getSelectionEx(); - TechDraw::DrawViewPart* baseFeat = nullptr; + TechDraw::DrawViewPart *baseFeat = nullptr; if (!selection.empty()) { - baseFeat = dynamic_cast(selection[0].getObject()); - if( baseFeat == nullptr ) { + baseFeat = dynamic_cast(selection[0].getObject()); + if (!baseFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("No base View in Selection.")); return; } - } else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), - QObject::tr("You must select a base View for the line.")); - return; + } + else { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), + QObject::tr("You must select a base View for the line.")); + return; } std::vector subNames; @@ -775,7 +776,7 @@ void execCenterLine(Gui::Command* cmd) return; } else { TechDraw::CenterLine* cl = baseFeat->getCenterLineBySelection(edgeNames.front()); - if (cl == nullptr) { + if (!cl) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("Selection is not a CenterLine.")); return; @@ -810,7 +811,7 @@ void CmdTechDraw2LineCenterLine::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -835,8 +836,7 @@ void exec2LineCenterLine(Gui::Command* cmd) TechDraw::DrawViewPart* dvp = nullptr; std::vector selectedEdges = getSelectedSubElements(cmd, dvp, "Edge"); - if ( (dvp == nullptr) || - (selectedEdges.empty()) ) { + if (!dvp || selectedEdges.empty()) { return; } @@ -847,7 +847,7 @@ void exec2LineCenterLine(Gui::Command* cmd) false)); } else if (selectedEdges.size() == 1) { TechDraw::CenterLine* cl = dvp->getCenterLineBySelection(selectedEdges.front()); - if (cl == nullptr) { + if (!cl) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("Selection is not a CenterLine.")); return; @@ -886,7 +886,7 @@ void CmdTechDraw2PointCenterLine::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -920,7 +920,7 @@ void exec2PointCenterLine(Gui::Command* cmd) } baseFeat = dynamic_cast(selection[0].getObject()); - if( baseFeat == nullptr ) { + if (!baseFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("No base View in Selection.")); return; @@ -959,7 +959,7 @@ void exec2PointCenterLine(Gui::Command* cmd) false)); } else if (!edgeNames.empty() && (edgeNames.size() == 1)) { TechDraw::CenterLine* cl = baseFeat->getCenterLineBySelection(edgeNames.front()); - if (cl == nullptr) { + if (!cl) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("Selection is not a CenterLine.")); return; @@ -999,7 +999,7 @@ void CmdTechDraw2PointCosmeticLine::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1080,7 +1080,7 @@ void execLine2Points(Gui::Command* cmd) //check if editing existing edge if (!edgeNames.empty() && (edgeNames.size() == 1)) { TechDraw::CosmeticEdge* ce = baseFeat->getCosmeticEdgeBySelection(edgeNames.front()); - if (ce == nullptr) { + if (!ce) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("Selection is not a Cosmetic Line.")); return; @@ -1154,7 +1154,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg) { Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1190,7 +1190,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg) objFeat = static_cast ((*itSel).getObject()); subNames = (*itSel).getSubNames(); } - if (objFeat == nullptr) { + if (!objFeat) { break; } std::vector cv2Delete; @@ -1275,7 +1275,7 @@ void CmdTechDrawDecorateLine::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1353,7 +1353,7 @@ void CmdTechDrawShowAll::activated(int iMsg) { Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1373,7 +1373,7 @@ void CmdTechDrawShowAll::activated(int iMsg) } baseFeat = dynamic_cast(selection[0].getObject()); - if (baseFeat == nullptr) { + if (!baseFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("No Part Views in this selection")); return; @@ -1419,7 +1419,7 @@ void CmdTechDrawWeldSymbol::activated(int iMsg) Q_UNUSED(iMsg); Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; diff --git a/src/Mod/TechDraw/Gui/CommandDecorate.cpp b/src/Mod/TechDraw/Gui/CommandDecorate.cpp index 1672bb77f4..929d8bb0a1 100644 --- a/src/Mod/TechDraw/Gui/CommandDecorate.cpp +++ b/src/Mod/TechDraw/Gui/CommandDecorate.cpp @@ -103,7 +103,7 @@ void CmdTechDrawHatch::activated(int iMsg) std::vector selection = getSelection().getSelectionEx(); auto partFeat( dynamic_cast(selection[0].getObject()) ); - if( partFeat == nullptr ) { + if (!partFeat) { return; } const std::vector &subNames = selection[0].getSubNames(); @@ -201,7 +201,7 @@ void CmdTechDrawGeometricHatch::activated(int iMsg) std::vector selection = getSelection().getSelectionEx(); auto objFeat( dynamic_cast(selection[0].getObject()) ); - if( objFeat == nullptr ) { + if (!objFeat) { return; } const std::vector &subNames = selection[0].getSubNames(); @@ -326,7 +326,7 @@ void CmdTechDrawToggleFrame::activated(int iMsg) Gui::ViewProvider* vp = activeGui->getViewProvider(page); ViewProviderPage* vpp = dynamic_cast(vp); - if (vpp == nullptr) { + if (!vpp) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No TechDraw Page"), QObject::tr("Need a TechDraw Page for this command")); return; diff --git a/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp index 2e1890cd18..af5d968160 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp @@ -2260,7 +2260,7 @@ namespace TechDrawGui { // check selection of getSelectionEx() and selection[0].getObject() if (_checkSelection(cmd, selection, message)) { objFeat = dynamic_cast(selection[0].getObject()); - if (objFeat == nullptr) { + if (!objFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr(message.c_str()), QObject::tr("No object selected")); diff --git a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp index 1a77370f18..48366f6a59 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp @@ -283,7 +283,7 @@ CmdTechDrawExtensionCircleCenterLinesGroup::CmdTechDrawExtensionCircleCenterLine void CmdTechDrawExtensionCircleCenterLinesGroup::activated(int iMsg) { Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -590,7 +590,7 @@ void CmdTechDrawExtensionThreadsGroup::activated(int iMsg) { // Base::Console().Message("CMD::TechDrawExtensionThreadsGroup - activated(%d)\n", iMsg); Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -766,7 +766,7 @@ void CmdTechDrawExtensionChangeLineAttributes::activated(int iMsg) { for (std::string name : subNames) { int num = DrawUtil::getIndexFromName(name); BaseGeomPtr baseGeo = objFeat->getGeomByIndex(num); - if (baseGeo != nullptr) { + if (baseGeo) { if (baseGeo->cosmetic) { if (baseGeo->source() == 1) { TechDraw::CosmeticEdge* cosEdgeTag = objFeat->getCosmeticEdgeBySelection(name); @@ -1068,7 +1068,7 @@ void CmdTechDrawExtensionDrawCirclesGroup::activated(int iMsg) { // Base::Console().Message("CMD::ExtensionDrawCirclesGroup - activated(%d)\n", iMsg); Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1299,7 +1299,7 @@ void CmdTechDrawExtensionLinePPGroup::activated(int iMsg) { // Base::Console().Message("CMD::ExtensionLinePPGroup - activated(%d)\n", iMsg); Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1506,7 +1506,7 @@ void execExtendShortenLine(Gui::Command* cmd, bool extend) { std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(name); if (geoType == "Edge") { TechDraw::BaseGeomPtr baseGeo = objFeat->getGeomByIndex(num); - if (baseGeo != nullptr) { + if (baseGeo) { if (baseGeo->geomType == TechDraw::GENERIC) { TechDraw::GenericPtr genLine = std::static_pointer_cast(baseGeo); Base::Vector3d P0 = genLine->points.at(0); @@ -1653,7 +1653,7 @@ void CmdTechDrawExtendShortenLineGroup::activated(int iMsg) { // Base::Console().Message("CMD::ExtendShortenLineGroup - activated(%d)\n", iMsg); Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); - if (dlg != nullptr) { + if (dlg) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), QObject::tr("Close active task dialog and try again.")); return; @@ -1910,7 +1910,7 @@ namespace TechDrawGui { } objFeat = dynamic_cast(selection[0].getObject()); - if (objFeat == nullptr) { + if (!objFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr(message.c_str()), QObject::tr("No object selected")); diff --git a/src/Mod/TechDraw/Gui/Grabber3d.cpp b/src/Mod/TechDraw/Gui/Grabber3d.cpp index 8f3660b483..7a670b3742 100644 --- a/src/Mod/TechDraw/Gui/Grabber3d.cpp +++ b/src/Mod/TechDraw/Gui/Grabber3d.cpp @@ -79,19 +79,19 @@ double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, //get the active view Gui::Document* guiDoc = Gui::Application::Instance->getDocument(appDoc); Gui::MDIView* mdiView = guiDoc->getActiveView(); - if (mdiView == nullptr) { + if (!mdiView) { Base::Console().Warning("G3d::copyActiveViewToSvgFile - no ActiveView - returning\n"); return result; } View3DInventor* view3d = qobject_cast(mdiView); - if (view3d == nullptr) { + if (!view3d) { Base::Console().Warning("G3d::copyActiveViewToSvgFile - no viewer for ActiveView - returning\n"); return result; } View3DInventorViewer* viewer = view3d->getViewer(); - if (viewer == nullptr) { + if (!viewer) { Base::Console().Warning("G3d::copyActiveViewToSvgFile - could not create viewer - returning\n"); return result; } diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 4e0ddf4050..2bf751164d 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -474,7 +474,7 @@ void MDIViewPage::fixOrphans(bool force) continue; } QGIView* qv = m_scene->findQViewForDocObj(dv); - if (qv == nullptr) { + if (!qv) { attachView(dv); } } @@ -490,7 +490,7 @@ void MDIViewPage::fixOrphans(bool force) if (!qv) continue; // already deleted? App::DocumentObject* obj = doc->getObject(qv->getViewName()); - if (obj == nullptr) { + if (!obj) { //no DrawView anywhere in Document m_scene->removeQView(qv); } else { @@ -1019,11 +1019,11 @@ void MDIViewPage::clearSceneSelection() //handle oddballs QGIViewDimension* dim = dynamic_cast(*it); - if (dim != nullptr) { + if (dim) { state = dim->getDatumLabel()->isSelected(); } else { QGIViewBalloon* bal = dynamic_cast(*it); - if (bal != nullptr) { + if (bal) { state = bal->getBalloonLabel()->isSelected(); } } @@ -1157,7 +1157,7 @@ void MDIViewPage::setTreeToSceneSelect(void) QList sceneSel = m_qgSceneSelected; for (QList::iterator it = sceneSel.begin(); it != sceneSel.end(); ++it) { QGIView *itemView = dynamic_cast(*it); - if(itemView == nullptr) { + if (!itemView) { QGIEdge *edge = dynamic_cast(*it); if(edge) { QGraphicsItem*parent = edge->parentItem(); @@ -1330,25 +1330,27 @@ bool MDIViewPage::compareSelections(std::vector treeSel, Q std::sort(treeNames.begin(),treeNames.end()); treeCount = treeNames.size(); - for (auto sn:sceneSel){ + for (auto sn : sceneSel) { QGIView *itemView = dynamic_cast(sn); - if(itemView == nullptr) { - QGIDatumLabel* dl = dynamic_cast(sn); - QGIPrimPath* pp = dynamic_cast(sn); //count Vertex/Edge/Face - if (pp != nullptr) { + if (!itemView) { + QGIDatumLabel *dl = dynamic_cast(sn); + QGIPrimPath *pp = dynamic_cast(sn);//count Vertex/Edge/Face + if (pp) { ppCount++; - } else if (dl != nullptr) { + } + else if (dl) { //get dim associated with this label - QGraphicsItem* qgi = dl->parentItem(); - if (qgi != nullptr) { - QGIViewDimension* vd = dynamic_cast(qgi); - if (vd != nullptr) { + QGraphicsItem *qgi = dl->parentItem(); + if (qgi) { + QGIViewDimension *vd = dynamic_cast(qgi); + if (vd) { std::string s = vd->getViewNameAsString(); sceneNames.push_back(s); } } } - } else { + } + else { std::string s = itemView->getViewNameAsString(); sceneNames.push_back(s); } @@ -1397,7 +1399,7 @@ void MDIViewPage::showStatusMsg(const char* s1, const char* s2, const char* s3) //return the MDIViewPage that owns the scene MDIViewPage *MDIViewPage::getFromScene(const QGSPage *scene) { - if (scene != nullptr && scene->parent() != nullptr) { + if (scene && scene->parent()) { return dynamic_cast(scene->parent()); } diff --git a/src/Mod/TechDraw/Gui/QGEPath.cpp b/src/Mod/TechDraw/Gui/QGEPath.cpp index 6cc4b92883..04cf91d1cc 100644 --- a/src/Mod/TechDraw/Gui/QGEPath.cpp +++ b/src/Mod/TechDraw/Gui/QGEPath.cpp @@ -347,13 +347,13 @@ void QGEPath::onEndEdit(void) std::vector QGEPath::getDeltasFromLeader(void) { std::vector qDeltas; - if (m_parentLeader == nullptr) { + if (!m_parentLeader) { Base::Console().Message("QGEP::getDeltasFromLeader - m_parentLeader is nullptr\n"); return qDeltas; } DrawLeaderLine* featLeader = m_parentLeader->getFeature(); - if (featLeader == nullptr) { + if (!featLeader) { Base::Console().Message("QGEP::getDeltasFromLeader - featLeader is nullptr\n"); return qDeltas; } @@ -385,7 +385,7 @@ void QGEPath::updateParent(void) void QGEPath::drawGhost(void) { // Base::Console().Message("QGEPath::drawGhost()\n"); - if (m_ghost->scene() == nullptr) { + if (!m_ghost->scene()) { m_ghost->setParentItem(this); } QPainterPath qpp; diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp index 58adadc082..5b60816669 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp @@ -201,7 +201,7 @@ void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent) // Base::Console().Message("QGILL::onSoureChange(%s)\n",newParent->getNameInDocument()); std::string parentName = newParent->getNameInDocument(); QGIView* qgiParent = getQGIVByName(parentName); - if (qgiParent != nullptr) { + if (qgiParent) { m_parentItem = qgiParent; setParentItem(m_parentItem); draw(); @@ -246,7 +246,7 @@ void QGILeaderLine::setPrettySel() { void QGILeaderLine::closeEdit(void) { // Base::Console().Message("QGIL::closeEdit()\n"); - if (m_editPath != nullptr) { + if (m_editPath) { m_editPath->onEndEdit(); //tell QEPath that edit session ended } } @@ -314,7 +314,7 @@ void QGILeaderLine::saveState(void) { // Base::Console().Message("QGILL::saveState()\n"); auto featLeader = getFeature(); - if (featLeader != nullptr) { + if (featLeader) { m_savePoints = featLeader->WayPoints.getValues(); m_saveX = featLeader->X.getValue(); m_saveY = featLeader->Y.getValue(); @@ -325,7 +325,7 @@ void QGILeaderLine::restoreState(void) { // Base::Console().Message("QGILL::restoreState()\n"); auto featLeader = getFeature(); - if (featLeader != nullptr) { + if (featLeader) { featLeader->WayPoints.setValues(m_savePoints); featLeader->X.setValue(m_saveX); featLeader->Y.setValue(m_saveY); @@ -372,7 +372,7 @@ void QGILeaderLine::draw() double scale = 1.0; TechDraw::DrawView* parent = featLeader->getBaseView(); - if (parent != nullptr) { + if (parent) { scale = parent->getScale(); } diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 93e7b91300..474ab003c0 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -157,13 +157,13 @@ QColor QGIPrimPath::getNormalColor() } QGraphicsItem* qparent = parentItem(); - if (qparent == nullptr) { + if (!qparent) { parent = nullptr; } else { parent = dynamic_cast (qparent); } - if (parent != nullptr) { + if (parent) { result = parent->getNormalColor(); } else { result = PreferencesGui::normalQColor(); @@ -177,13 +177,13 @@ QColor QGIPrimPath::getPreColor() QColor result; QGIView *parent; QGraphicsItem* qparent = parentItem(); - if (qparent == nullptr) { + if (!qparent) { parent = nullptr; } else { parent = dynamic_cast (qparent); } - if (parent != nullptr) { + if (parent) { result = parent->getPreColor(); } else { result = PreferencesGui::preselectQColor(); @@ -196,13 +196,13 @@ QColor QGIPrimPath::getSelectColor() QColor result; QGIView *parent; QGraphicsItem* qparent = parentItem(); - if (qparent == nullptr) { + if (!qparent) { parent = nullptr; } else { parent = dynamic_cast (qparent); } - if (parent != nullptr) { + if (parent) { result = parent->getSelectColor(); } else { result = PreferencesGui::selectQColor(); @@ -279,9 +279,9 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event) //wf: this seems a bit of a hack. does it mess up selection of QGIPP?? QGIView *parent; QGraphicsItem* qparent = parentItem(); - if (qparent != nullptr) { + if (qparent) { parent = dynamic_cast (qparent); - if (parent != nullptr) { + if (parent) { // Base::Console().Message("QGIPP::mousePressEvent - passing event to QGIV parent\n"); parent->mousePressEvent(event); } else { diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index 8589ba93bd..57a91c4fcb 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -180,7 +180,7 @@ QGIView * QGIProjGroup::getAnchorQItem() const // Get the currently assigned anchor view App::DocumentObject *anchorObj = getDrawView()->Anchor.getValue(); auto anchorView( dynamic_cast(anchorObj) ); - if( anchorView == nullptr ) { + if (!anchorView) { return nullptr; } diff --git a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp index a35f07cc84..6c7b52abcb 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp @@ -157,7 +157,7 @@ void ViewProviderPage::removeMDIView(void) Gui::getMainWindow()->removeWindow(m_mdiView); Gui::MDIView* aw = Gui::getMainWindow()->activeWindow(); //WF: this bit should be in the remove window logic, not here. - if (aw == nullptr) { + if (!aw) { return; } aw->showMaximized(); @@ -338,7 +338,7 @@ std::vector ViewProviderPage::claimChildren(void) const //DrawRichAnno with no parent is child of Page TechDraw::DrawRichAnno* dra = dynamic_cast (*it); if (dra) { - if (dra->AnnoParent.getValue() == nullptr) { + if (!dra->AnnoParent.getValue()) { temp.push_back(*it); //no parent, belongs to page } continue; //has a parent somewhere else