[TD] remove some more superfluous nullptr checks

This commit is contained in:
Uwe
2022-07-20 02:53:48 +02:00
parent 8304a0942e
commit 31bc9f3913
31 changed files with 84 additions and 128 deletions

View File

@@ -116,7 +116,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::s
}
int idx = DrawUtil::getIndexFromName(name);
TechDraw::VertexPtr v = dvp->getProjVertexByIndex(idx);
if (v == nullptr) {
if (!v) {
return result;
}
if (!v->cosmeticTag.empty()) {

View File

@@ -95,7 +95,7 @@ void DrawDimHelper::makeExtentDim(DrawViewPart* dvp,
{
// Base::Console().Message("DDH::makeExtentDim() - dvp: %s edgeNames: %d\n",
// dvp->Label.getValue(), edgeNames.size());
if (dvp == nullptr) {
if (!dvp) {
// Base::Console().Message("DDH::makeExtentDim - dvp: %X\n", dvp);
return;
}

View File

@@ -332,7 +332,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
int i = 0;
for (auto& e: resultEdges) {
TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e);
if (base == nullptr) {
if (!base) {
Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n",i);
throw Base::ValueError("DGH::getTrimmedLines - baseFactory failed");
}
@@ -481,7 +481,7 @@ std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
int i = 0;
for (auto& e: candidates) {
TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e);
if (base == nullptr) {
if (!base) {
Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n",i);
throw Base::ValueError("DGH::getFaceOverlay - baseFactory failed");
}

View File

@@ -287,7 +287,7 @@ int DrawPage::removeView(App::DocumentObject *docObj)
return -1;
App::Document* doc = docObj->getDocument();
if (doc == nullptr) {
if (!doc) {
return -1;
}
@@ -300,7 +300,7 @@ int DrawPage::removeView(App::DocumentObject *docObj)
std::vector<App::DocumentObject*>::const_iterator it = currViews.begin();
for (; it != currViews.end(); it++) {
App::Document* viewDoc = (*it)->getDocument();
if (viewDoc == nullptr) {
if (!viewDoc) {
continue;
}

View File

@@ -549,7 +549,7 @@ std::pair<Base::Vector3d,Base::Vector3d> DrawProjGroup::getDirsFromFront(std::st
Base::Vector3d projDir, rotVec;
DrawProjGroupItem* anch = getAnchor();
if (anch == nullptr) {
if (!anch) {
Base::Console().Warning("DPG::getDirsFromFront - %s - No Anchor!\n",Label.getValue());
throw Base::RuntimeError("Project Group missing Anchor projection item");
}

View File

@@ -99,7 +99,7 @@ DrawView::~DrawView()
App::DocumentObjectExecReturn *DrawView::execute(void)
{
// Base::Console().Message("DV::execute() - %s touched: %d\n", getNameInDocument(), isTouched());
if (findParentPage() == nullptr) {
if (!findParentPage()) {
return App::DocumentObject::execute();
}
handleXYLock();

View File

@@ -106,7 +106,7 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void)
if (sourceObj) {
//if (sourceObj is not ArchSection) return
App::Property* proxy = sourceObj->getPropertyByName("Proxy");
if (proxy == nullptr) {
if (!proxy) {
Base::Console().Error("DVA::execute - %s is not an ArchSection\n", sourceObj->Label.getValue());
//this is definitely not an ArchSection
return DrawView::execute();

View File

@@ -109,13 +109,11 @@ App::DocumentObjectExecReturn *DrawViewDimExtent::execute(void)
}
App::DocumentObject* docObj = Source.getValue();
if (docObj == nullptr) {
if (!docObj)
return App::DocumentObject::StdReturn;
}
DrawViewPart* dvp = dynamic_cast<DrawViewPart*>(docObj);
if (dvp == nullptr) {
if (!dvp)
return App::DocumentObject::StdReturn;
}
double tolerance = 0.00001;
std::vector<std::string> edgeNames = getSubNames();
@@ -186,9 +184,8 @@ pointPair DrawViewDimExtent::getPointsTwoVerts()
TechDraw::VertexPtr v0 = nullptr;
TechDraw::VertexPtr v1 = nullptr;
TechDraw::DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
if (!dvp)
return result;
}
std::vector<std::string> cTags = CosmeticTags.getValues();
if (cTags.size() > 1) {

View File

@@ -389,9 +389,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
return App::DocumentObject::StdReturn;
}
DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
if (!dvp)
return App::DocumentObject::StdReturn;
}
if (!has2DReferences()) { //too soon?
if (isRestoring() ||
@@ -1163,13 +1162,11 @@ double DrawViewDimension::getDimValue()
}
return result;
}
if (getViewPart() == nullptr) {
if (!getViewPart())
return result;
}
if (!getViewPart()->hasGeometry() ) { //happens when loading saved document
if (!getViewPart()->hasGeometry()) //happens when loading saved document
return result;
}
if (MeasureType.isValue("True")) {
// True Values
@@ -1278,8 +1275,7 @@ pointPair DrawViewDimension::getPointsTwoEdges()
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
TechDraw::BaseGeomPtr geom0 = getViewPart()->getGeomByIndex(idx0);
TechDraw::BaseGeomPtr geom1 = getViewPart()->getGeomByIndex(idx1);
if ((geom0 == nullptr) ||
(geom1 == nullptr) ) {
if (!geom0 || !geom1) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (2)\n",getNameInDocument());
return result;
}
@@ -1297,8 +1293,7 @@ pointPair DrawViewDimension::getPointsTwoVerts()
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
TechDraw::VertexPtr v0 = getViewPart()->getProjVertexByIndex(idx0);
TechDraw::VertexPtr v1 = getViewPart()->getProjVertexByIndex(idx1);
if ((v0 == nullptr) ||
(v1 == nullptr) ) {
if (!v0 || !v1) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n",getNameInDocument());
return result;
}
@@ -1322,7 +1317,7 @@ pointPair DrawViewDimension::getPointsEdgeVert()
e = getViewPart()->getGeomByIndex(idx1);
v = getViewPart()->getProjVertexByIndex(idx0);
}
if ((v == nullptr) || (e == nullptr) ) {
if (!v || !e) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (4)\n", getNameInDocument());
return result;
}
@@ -1378,13 +1373,13 @@ bool DrawViewDimension::checkReferences2D() const
int idx = DrawUtil::getIndexFromName(s);
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
if (geom == nullptr) {
if (!geom) {
result = false;
break;
}
} else if (DrawUtil::getGeomTypeFromName(s) == "Vertex") {
TechDraw::VertexPtr v = getViewPart()->getProjVertexByIndex(idx);
if (v == nullptr) {
if (!v) {
result = false;
break;
}
@@ -1512,7 +1507,7 @@ bool DrawViewDimension::leaderIntersectsArc(Base::Vector3d s, Base::Vector3d poi
void DrawViewDimension::saveArrowPositions(const Base::Vector2d positions[])
{
if (positions == nullptr) {
if (!positions) {
m_arrowPositions.first = Base::Vector3d(0.0, 0.0, 0.0);
m_arrowPositions.second = Base::Vector3d(0.0, 0.0, 0.0);
} else {

View File

@@ -1185,7 +1185,7 @@ void execHExtent(Gui::Command* cmd)
}
baseFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
if( baseFeat == nullptr ) {
if (!baseFeat) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
QObject::tr("No base View in Selection."));
return;
@@ -1273,7 +1273,7 @@ void execVExtent(Gui::Command* cmd)
baseFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
if( baseFeat == nullptr ) {
if (!baseFeat) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
QObject::tr("No base View in Selection."));
return;
@@ -1481,9 +1481,8 @@ int _isValidSingleEdge(Gui::Command* cmd) {
auto selection( cmd->getSelection().getSelectionEx() );
auto objFeat( dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject()) );
if( objFeat == nullptr ) {
if (!objFeat)
return isInvalid;
}
const std::vector<std::string> SubNames = selection[0].getSubNames();
if (SubNames.size() != 1 ||
@@ -1579,7 +1578,7 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
TechDraw::BaseGeomPtr geom0 = objFeat0->getGeomByIndex(GeoId0);
TechDraw::BaseGeomPtr geom1 = objFeat0->getGeomByIndex(GeoId1);
if ((geom0 == nullptr) || (geom1 == nullptr)) { // missing gometry
if (!geom0 || !geom1) { // missing gometry
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1);
return isInvalid;
}
@@ -1634,7 +1633,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
}
e = objFeat0->getGeomByIndex(eId);
v = objFeat0->getProjVertexByIndex(vId);
if ((e == nullptr) || (v == nullptr)) {
if (!e || !v) {
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId);
return false;
}

View File

@@ -340,7 +340,7 @@ void QGILeaderLine::updateView(bool update)
// Base::Console().Message("QGIL::updateView() %s\n",getViewObject()->getNameInDocument());
Q_UNUSED(update);
auto featLeader( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
if ( featLeader == nullptr ) {
if (!featLeader) {
Base::Console().Warning("QGILL::updateView - no feature!\n");
return;
}
@@ -600,7 +600,7 @@ QColor QGILeaderLine::getNormalColor()
m_colNormal = PreferencesGui::leaderQColor();
auto lead( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
if( lead == nullptr ) {
if (!lead) {
// Base::Console().Message("QGILL::getNormalColor - no feature\n");
return m_colNormal;
}

View File

@@ -147,15 +147,14 @@ void QGIRichAnno::updateView(bool update)
// Base::Console().Message("QGIRA::updateView() - %s\n", getViewName());
Q_UNUSED(update);
auto annoFeat( dynamic_cast<TechDraw::DrawRichAnno*>(getViewObject()) );
if ( annoFeat == nullptr ) {
if (!annoFeat) {
Base::Console().Log("QGIRA::updateView - no feature!\n");
return;
}
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return;
}
if (annoFeat->X.isTouched() ||
annoFeat->Y.isTouched()) {
float x = Rez::guiX(annoFeat->X.getValue());
@@ -177,22 +176,19 @@ void QGIRichAnno::drawBorder()
void QGIRichAnno::draw()
{
// Base::Console().Log("QGIRA::draw() - %s - parent: %X\n",getFeature()->getNameInDocument(), parentItem());
if (!isVisible()) {
if (!isVisible())
// Base::Console().Message("QGIRA::draw - not visible\n");
return;
}
TechDraw::DrawRichAnno* annoFeat = getFeature();
if((!annoFeat) ) {
if (!annoFeat)
// Base::Console().Message("QGIRA::draw - no feature\n");
return;
}
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getFeature()));
if ( vp == nullptr ) {
if (!vp)
// Base::Console().Message("QGIRA::draw - no viewprovider\n");
return;
}
// double appX = Rez::guiX(annoFeat->X.getValue());
// double appY = Rez::guiX(annoFeat->Y.getValue());
@@ -326,13 +322,11 @@ QPen QGIRichAnno::rectPen() const
{
QPen pen;
const auto sym( dynamic_cast<TechDraw::DrawRichAnno*>(getViewObject()) );
if( sym == nullptr ) {
if (!sym)
return pen;
}
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return pen;
}
double rectWeight = Rez::guiX(vp->LineWidth.getValue());
Qt::PenStyle rectStyle = (Qt::PenStyle) vp->LineStyle.getValue();
@@ -366,9 +360,8 @@ void QGIRichAnno::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) {
Q_UNUSED(event);
TechDraw::DrawRichAnno *annotation = dynamic_cast<TechDraw::DrawRichAnno *>(getViewObject());
if (annotation == nullptr) {
if (!annotation)
return;
}
QString text = QString::fromUtf8(annotation->AnnoText.getValue());

View File

@@ -59,7 +59,7 @@ QVariant QGITemplate::itemChange(GraphicsItemChange change, const QVariant &valu
void QGITemplate::setTemplate(TechDraw::DrawTemplate *obj)
{
if(obj == nullptr)
if (!obj)
return;
pageTemplate = obj;

View File

@@ -399,7 +399,7 @@ TechDraw::DrawView * QGIView::getViewObject() const
void QGIView::setViewFeature(TechDraw::DrawView *obj)
{
if(obj == nullptr)
if (!obj)
return;
viewObj = obj;
@@ -465,9 +465,8 @@ void QGIView::drawBorder()
{
// Base::Console().Message("QGIV::drawBorder() - %s\n",getViewName());
auto feat = getViewObject();
if (feat == nullptr) {
if (!feat)
return;
}
drawCaption(); //always draw caption

View File

@@ -96,7 +96,7 @@ void QGIViewAnnotation::setViewAnnoFeature(TechDraw::DrawViewAnnotation *obj)
void QGIViewAnnotation::updateView(bool update)
{
auto viewAnno( dynamic_cast<TechDraw::DrawViewAnnotation *>(getViewObject()) );
if( viewAnno == nullptr)
if (!viewAnno)
return;
if (update ||
@@ -129,7 +129,7 @@ void QGIViewAnnotation::draw()
void QGIViewAnnotation::drawAnnotation()
{
auto viewAnno( dynamic_cast<TechDraw::DrawViewAnnotation *>(getViewObject()) );
if( viewAnno == nullptr ) {
if (!viewAnno) {
return;
}
@@ -189,7 +189,7 @@ void QGIViewAnnotation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
Q_UNUSED(event);
TechDraw::DrawViewAnnotation *annotation = dynamic_cast<TechDraw::DrawViewAnnotation *>(getViewObject());
if (annotation == nullptr) {
if (!annotation) {
return;
}

View File

@@ -393,7 +393,7 @@ void QGIViewBalloon::hover(bool state)
void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloon)
{
// Base::Console().Message("QGIVB::setViewPartFeature()\n");
if(balloon == nullptr)
if (!balloon)
return;
setViewFeature(static_cast<TechDraw::DrawView *>(balloon));

View File

@@ -70,9 +70,8 @@ QVariant QGIViewClip::itemChange(GraphicsItemChange change, const QVariant &valu
void QGIViewClip::updateView(bool update)
{
auto viewClip( dynamic_cast<TechDraw::DrawViewClip *>(getViewObject()) );
if( viewClip == nullptr ) {
if (!viewClip)
return;
}
if (update ||
viewClip->isTouched() ||
@@ -103,9 +102,8 @@ void QGIViewClip::drawClip()
{
auto viewClip( dynamic_cast<TechDraw::DrawViewClip *>(getViewObject()) );
if( viewClip == nullptr ) {
if (!viewClip)
return;
}
prepareGeometryChange();
double h = viewClip->Height.getValue();

View File

@@ -566,7 +566,7 @@ void QGIViewDimension::hover(bool state)
void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj)
{
// Base::Console().Message("QGIVD::setViewPartFeature()\n");
if(obj == nullptr)
if (!obj)
return;
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
@@ -617,14 +617,13 @@ void QGIViewDimension::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
void QGIViewDimension::updateView(bool update)
{
Q_UNUSED(update);
auto dim( dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject()) );
if( dim == nullptr )
auto dim(dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject()));
if (!dim)
return;
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return;
}
if (update||
dim->X.isTouched() ||

View File

@@ -90,9 +90,8 @@ void QGIViewImage::setViewImageFeature(TechDraw::DrawViewImage *obj)
void QGIViewImage::updateView(bool update)
{
auto viewImage( dynamic_cast<TechDraw::DrawViewImage *>(getViewObject()) );
if( viewImage == nullptr ) {
if (!viewImage)
return;
}
if (update ||
viewImage->isTouched() ||
@@ -120,9 +119,8 @@ void QGIViewImage::draw()
return;
auto vp = static_cast<ViewProviderImage*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return;
}
bool crop = vp->Crop.getValue();
drawImage();
@@ -141,9 +139,8 @@ void QGIViewImage::draw()
void QGIViewImage::drawImage()
{
auto viewImage( dynamic_cast<TechDraw::DrawViewImage *>(getViewObject()) );
if( viewImage == nullptr ) {
if (!viewImage)
return;
}
if (!viewImage->ImageIncluded.isEmpty()) {
QString fileSpec = QString::fromUtf8(viewImage->ImageIncluded.getValue(),strlen(viewImage->ImageIncluded.getValue()));

View File

@@ -154,9 +154,8 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot)
Q_UNUSED(rot);
QPainterPath path;
if (baseGeom == nullptr) {
if (!baseGeom)
return path;
}
switch(baseGeom->geomType) {
case CIRCLE: {
@@ -411,24 +410,20 @@ void QGIViewPart::updateView(bool update)
{
// Base::Console().Message("QGIVP::updateView() - %s\n", getViewObject()->getNameInDocument());
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
if( viewPart == nullptr ) {
if (!viewPart)
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return;
}
if (update ) {
if (update)
draw();
}
QGIView::updateView(update);
}
void QGIViewPart::draw() {
if (!isVisible()) {
if (!isVisible())
return;
}
drawViewPart();
drawMatting();
@@ -440,9 +435,8 @@ void QGIViewPart::draw() {
void QGIViewPart::drawViewPart()
{
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
if ( viewPart == nullptr ) {
if (!viewPart)
return;
}
// Base::Console().Message("QGIVP::DVP() - %s / %s\n", viewPart->getNameInDocument(), viewPart->Label.getValue());
if (!viewPart->hasGeometry()) {
removePrimitives(); //clean the slate
@@ -451,9 +445,8 @@ void QGIViewPart::drawViewPart()
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
if (!vp)
return;
}
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor;
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
@@ -834,9 +827,8 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
if (!viewPart) {
return;
}
if (viewSection == nullptr) {
if (!viewSection)
return;
}
if (!viewSection->hasGeometry()) {
return;

View File

@@ -67,19 +67,15 @@ void QGIViewSection::draw()
void QGIViewSection::drawSectionFace()
{
auto section( dynamic_cast<TechDraw::DrawViewSection *>(getViewObject()) );
if( section == nullptr ) {
if (!section)
return;
}
if ( !section->hasGeometry()) {
if (!section->hasGeometry())
return;
}
Gui::ViewProvider* gvp = QGIView::getViewProvider(section);
ViewProviderViewSection* sectionVp = dynamic_cast<ViewProviderViewSection*>(gvp);
if ((sectionVp == nullptr) ||
(!sectionVp->ShowCutSurface.getValue())) {
if (!sectionVp || !sectionVp->ShowCutSurface.getValue())
return;
}
float lineWidth = sectionVp->LineWidth.getValue();
@@ -152,9 +148,8 @@ void QGIViewSection::updateView(bool update)
{
Q_UNUSED(update);
auto viewPart( dynamic_cast<TechDraw::DrawViewSection *>(getViewObject()) );
if( viewPart == nullptr ) {
if (!viewPart)
return;
}
draw();
QGIView::updateView(update);
}

View File

@@ -91,9 +91,8 @@ void QGIViewSymbol::setViewSymbolFeature(TechDraw::DrawViewSymbol *obj)
void QGIViewSymbol::updateView(bool update)
{
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
if( viewSymbol == nullptr ) {
if (!viewSymbol)
return;
}
if (update ||
viewSymbol->isTouched() ||
@@ -121,9 +120,8 @@ void QGIViewSymbol::draw()
void QGIViewSymbol::drawSvg()
{
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
if( viewSymbol == nullptr ) {
if (!viewSymbol)
return;
}
double rezfactor = Rez::getRezFactor();
double scaling = viewSymbol->getScale();

View File

@@ -149,11 +149,10 @@ void QGIWeldSymbol::updateView(bool update)
// Base::Console().Message("QGIWS::updateView()\n");
Q_UNUSED(update);
auto viewWeld( dynamic_cast<TechDraw::DrawWeldSymbol*>(getViewObject()) );
if( viewWeld == nullptr ) {
if (!viewWeld)
return;
}
if ( getFeature() == nullptr ) {
if (!getFeature()) {
Base::Console().Warning("QGIWS::updateView - no feature!\n");
return;
}
@@ -189,7 +188,7 @@ void QGIWeldSymbol::draw()
void QGIWeldSymbol::drawTile(TechDraw::DrawTileWeld* tileFeat)
{
// Base::Console().Message("QGIWS::drawTile() - tileFeat: %X\n", tileFeat);
if (tileFeat == nullptr) {
if (!tileFeat) {
Base::Console().Message("QGIWS::drawTile - tile is null\n");
return;
}

View File

@@ -159,7 +159,7 @@ int QGSPage::addQView(QGIView *view)
{
//don't add twice!
QGIView* existing = getQGIVByName(view->getViewName());
if (existing == nullptr) {
if (!existing) {
addItem(view);
// Find if it belongs to a parent

View File

@@ -155,8 +155,7 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView(void)
App::DocumentObject* newObj = m_pageFeat->getDocument()->getObject(symbolName.c_str());
TechDraw::DrawViewSymbol* newSym = dynamic_cast<TechDraw::DrawViewSymbol*>(newObj);
if ( (newObj == nullptr) ||
(newSym == nullptr) ) {
if (!newObj || !newSym) {
throw Base::RuntimeError("TaskActiveView - new symbol object not found");
}

View File

@@ -320,7 +320,7 @@ void TaskCenterLine::createCenterLine(void)
// the centerline creation can fail if m_type is edge and both selected edges are horizontal
// because we attempt by default to create a vertical centerline
if (cl == nullptr) { // try a horizontal line
if (!cl) { // try a horizontal line
cl = CenterLine::CenterLineBuilder(m_partFeat, m_subNames, CenterLine::CLMODE::HORIZONTAL, false);
if (cl) {
m_mode = CenterLine::CLMODE::HORIZONTAL;
@@ -330,7 +330,7 @@ void TaskCenterLine::createCenterLine(void)
}
}
if (cl == nullptr) {
if (!cl) {
Base::Console().Log("TCL::createCenterLine - CenterLine creation failed!\n");
Gui::Command::abortCommand();
return;
@@ -379,7 +379,7 @@ void TaskCenterLine::updateOrientation(void)
CenterLine* cl = CenterLine::CenterLineBuilder(m_partFeat, m_subNames, orientation, m_cl->m_flip2Line);
if (cl == nullptr) { // try another orientation
if (!cl) { // try another orientation
if (orientation == CenterLine::CLMODE::VERTICAL)
orientation = CenterLine::CLMODE::HORIZONTAL;
else if (orientation == CenterLine::CLMODE::HORIZONTAL)

View File

@@ -208,7 +208,7 @@ void TaskCosVertex::startTracker(void)
return;
}
if (m_tracker == nullptr) {
if (!m_tracker) {
m_tracker = new QGTracker(m_scene, m_trackerMode);
QObject::connect(
m_tracker, SIGNAL(drawingFinished(std::vector<QPointF>, QGIView*)),
@@ -244,7 +244,7 @@ void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParen
DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
if (dpgi) {
DrawProjGroup* dpg = dpgi->getPGroup();
if (dpg == nullptr) {
if (!dpg) {
Base::Console().Message("TCV:onTrackerFinished - projection group is confused\n");
//TODO::throw something.
return;

View File

@@ -86,7 +86,7 @@ TaskCosmeticLine::TaskCosmeticLine(TechDraw::DrawViewPart* partFeat,
//existence of partFeat is checked in calling command
m_ce = m_partFeat->getCosmeticEdgeBySelection(m_edgeName);
if (m_ce == nullptr) {
if (!m_ce) {
Base::Console().Error("TaskCosmeticLine - bad parameters. Can not proceed.\n");
return;
}

View File

@@ -144,9 +144,8 @@ TaskProjGroup::~TaskProjGroup()
void TaskProjGroup::saveGroupState()
{
// Base::Console().Message("TPG::saveGroupState()\n");
if (multiView == nullptr) {
if (!multiView)
return;
}
m_saveSource = multiView->Source.getValues();
m_saveProjType = multiView->ProjectionType.getValueAsString();
@@ -170,9 +169,8 @@ void TaskProjGroup::saveGroupState()
void TaskProjGroup::restoreGroupState()
{
Base::Console().Message("TPG::restoreGroupState()\n");
if (multiView == nullptr) {
if (!multiView)
return;
}
multiView->ProjectionType.setValue(m_saveProjType.c_str());
multiView->ScaleType.setValue(m_saveScaleType.c_str());
@@ -460,9 +458,8 @@ const char * TaskProjGroup::viewChkIndexToCStr(int index)
}
void TaskProjGroup::setupViewCheckboxes(bool addConnections)
{
if ( multiView == nullptr ) {
if (!multiView)
return;
}
// There must be a better way to construct this list...
QCheckBox * viewCheckboxes[] = { ui->chkView0,

View File

@@ -100,7 +100,7 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
m_annoFeat = m_annoVP->getFeature();
m_basePage = m_annoFeat->findParentPage();
if ( m_basePage == nullptr ) {
if (!m_basePage) {
Base::Console().Error("TaskRichAnno - bad parameters (2). Can not proceed.\n");
return;
}
@@ -352,7 +352,7 @@ void TaskRichAnno::createAnnoFeature()
annoName.c_str(),m_baseFeat->getNameInDocument());
}
App::DocumentObject* obj = m_basePage->getDocument()->getObject(annoName.c_str());
if (obj == nullptr) {
if (!obj) {
throw Base::RuntimeError("TaskRichAnno - new RichAnno object not found");
}
if (obj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
@@ -424,7 +424,7 @@ void TaskRichAnno::commonFeatureUpdate(void)
void TaskRichAnno::removeFeature(void)
{
// Base::Console().Message("TRA::removeFeature()\n");
if (m_annoFeat == nullptr)
if (!m_annoFeat)
return;
if (m_createMode) {

View File

@@ -255,9 +255,8 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
std::vector<TechDraw::DrawPage*> pages = getViewObject()->findAllParentPages();
if (pages.size() > 1) {
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
if (guiDoc == nullptr) {
if (!guiDoc)
return;
}
for (auto& p : pages) {
std::vector<App::DocumentObject*> views = p->Views.getValues();
for (auto& v: views) {