[TD] Gui: remove more superfluous nullptr checks
This commit is contained in:
@@ -145,7 +145,7 @@ void QGIView::isVisible(bool state)
|
||||
auto vp = QGIView::getViewProvider(feat);
|
||||
if (vp) {
|
||||
Gui::ViewProviderDocumentObject* vpdo = dynamic_cast<Gui::ViewProviderDocumentObject*>(vp);
|
||||
if (vpdo != nullptr) {
|
||||
if (vpdo) {
|
||||
vpdo->Visibility.setValue(state);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ bool QGIView::isVisible(void)
|
||||
auto vp = QGIView::getViewProvider(feat);
|
||||
if (vp) {
|
||||
Gui::ViewProviderDocumentObject* vpdo = dynamic_cast<Gui::ViewProviderDocumentObject*>(vp);
|
||||
if (vpdo != nullptr) {
|
||||
if (vpdo) {
|
||||
result = vpdo->Visibility.getValue();
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ QGVPage* QGIView::getGraphicsView(TechDraw::DrawView* dv)
|
||||
QGVPage* graphicsView = nullptr;
|
||||
Gui::ViewProvider* vp = getViewProvider(dv);
|
||||
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(vp);
|
||||
if (vpdv != nullptr) {
|
||||
if (vpdv) {
|
||||
MDIViewPage* mdi = vpdv->getMDIViewPage();
|
||||
if (mdi) {
|
||||
graphicsView = mdi->getQGVPage();
|
||||
@@ -634,7 +634,7 @@ QGSPage* QGIView::getGraphicsScene(TechDraw::DrawView* dv)
|
||||
QGSPage* graphicsScene = nullptr;
|
||||
Gui::ViewProvider* vp = getViewProvider(dv);
|
||||
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(vp);
|
||||
if (vpdv != nullptr) {
|
||||
if (vpdv) {
|
||||
MDIViewPage* mdi = vpdv->getMDIViewPage();
|
||||
if (mdi) {
|
||||
graphicsScene = mdi->getQGSPage();
|
||||
|
||||
@@ -148,7 +148,7 @@ std::vector<QGIView *> QGSPage::getViews() const
|
||||
QList<QGraphicsItem*> items = this->items();
|
||||
for (auto& v:items) {
|
||||
QGIView* qv = dynamic_cast<QGIView*>(v);
|
||||
if (qv != nullptr) {
|
||||
if (qv) {
|
||||
result.push_back(qv);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ int QGSPage::addQView(QGIView *view)
|
||||
|
||||
int QGSPage::removeQView(QGIView *view)
|
||||
{
|
||||
if (view != nullptr) {
|
||||
if (view) {
|
||||
removeQViewFromScene(view);
|
||||
delete view;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ int QGSPage::removeQViewByName(const char* name)
|
||||
void QGSPage::removeQViewFromScene(QGIView *view)
|
||||
{
|
||||
QGIView* qgParent = dynamic_cast<QGIView*>(view->parentItem());
|
||||
if (qgParent != nullptr) {
|
||||
if (qgParent) {
|
||||
qgParent->removeChild(view);
|
||||
} else {
|
||||
removeItem(view);
|
||||
@@ -236,7 +236,7 @@ QGIView * QGSPage::addViewPart(TechDraw::DrawViewPart *part)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addViewPart(%s)\n", part->getNameInDocument());
|
||||
QGIView* existing = findQViewForDocObj(part);
|
||||
if (existing != nullptr) {
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
@@ -470,10 +470,10 @@ QGIView * QGSPage::addRichAnno(TechDraw::DrawRichAnno* anno)
|
||||
TechDraw::DrawView* parentDV = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = anno->AnnoParent.getValue();
|
||||
if (parentObj != nullptr) {
|
||||
if (parentObj) {
|
||||
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
}
|
||||
if (parentDV != nullptr) {
|
||||
if (parentDV) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
annoGroup = new QGIRichAnno(parentQV, anno);
|
||||
annoGroup->updateView(true);
|
||||
@@ -492,15 +492,15 @@ QGIView * QGSPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weld)
|
||||
TechDraw::DrawView* parentDV = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = weld->Leader.getValue();
|
||||
if (parentObj != nullptr) {
|
||||
if (parentObj) {
|
||||
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
} else {
|
||||
// Base::Console().Message("QGVP::addWeldSymbol - no parent doc obj\n");
|
||||
}
|
||||
if (parentDV != nullptr) {
|
||||
if (parentDV) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
QGILeaderLine* leadParent = dynamic_cast<QGILeaderLine*>(parentQV);
|
||||
if (leadParent != nullptr) {
|
||||
if (leadParent) {
|
||||
weldGroup = new QGIWeldSymbol(leadParent);
|
||||
weldGroup->setFeature(weld); //for QGIWS
|
||||
weldGroup->setViewFeature(weld); //for QGIV
|
||||
@@ -546,7 +546,7 @@ QGIView* QGSPage::getQGIVByName(std::string name)
|
||||
}
|
||||
|
||||
//find the parent of a QGIV based on the corresponding feature's parentage
|
||||
QGIView * QGSPage::findParent(QGIView *view) const
|
||||
QGIView *QGSPage::findParent(QGIView *view) const
|
||||
{
|
||||
const std::vector<QGIView *> qviews = getViews();
|
||||
TechDraw::DrawView *myFeat = view->getViewObject();
|
||||
@@ -554,14 +554,14 @@ QGIView * QGSPage::findParent(QGIView *view) const
|
||||
//If type is dimension we check references first
|
||||
TechDraw::DrawViewDimension *dim = nullptr;
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myFeat);
|
||||
if(dim) {
|
||||
if (dim) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
|
||||
if(objs.size() > 0) {
|
||||
if (objs.size() > 0) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
// Attach the dimension to the first object's group
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), objs.at(0)->getNameInDocument()) == 0) {
|
||||
for (std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if (strcmp((*it)->getViewName(), objs.at(0)->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@@ -572,13 +572,13 @@ QGIView * QGSPage::findParent(QGIView *view) const
|
||||
TechDraw::DrawViewBalloon *balloon = nullptr;
|
||||
balloon = dynamic_cast<TechDraw::DrawViewBalloon *>(myFeat);
|
||||
|
||||
if(balloon) {
|
||||
App::DocumentObject* obj = balloon->SourceView.getValue();
|
||||
if (balloon) {
|
||||
App::DocumentObject *obj = balloon->SourceView.getValue();
|
||||
|
||||
if(obj) {
|
||||
if (obj) {
|
||||
// Attach the dimension to the first object's group
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), obj->getNameInDocument()) == 0) {
|
||||
for (std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if (strcmp((*it)->getViewName(), obj->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@@ -586,16 +586,16 @@ QGIView * QGSPage::findParent(QGIView *view) const
|
||||
}
|
||||
|
||||
// Check if part of view collection
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
for (std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
QGIViewCollection *grp = nullptr;
|
||||
grp = dynamic_cast<QGIViewCollection *>(*it);
|
||||
if(grp) {
|
||||
if (grp) {
|
||||
TechDraw::DrawViewCollection *collection = nullptr;
|
||||
collection = dynamic_cast<TechDraw::DrawViewCollection *>(grp->getViewObject());
|
||||
if(collection) {
|
||||
if (collection) {
|
||||
std::vector<App::DocumentObject *> objs = collection->Views.getValues();
|
||||
for( std::vector<App::DocumentObject *>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
if(strcmp(myFeat->getNameInDocument(), (*it)->getNameInDocument()) == 0)
|
||||
for (std::vector<App::DocumentObject *>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
if (strcmp(myFeat->getNameInDocument(), (*it)->getNameInDocument()) == 0)
|
||||
|
||||
return grp;
|
||||
}
|
||||
@@ -603,16 +603,16 @@ QGIView * QGSPage::findParent(QGIView *view) const
|
||||
}
|
||||
}
|
||||
|
||||
//If type is LeaderLine we check LeaderParent
|
||||
//If type is LeaderLine we check LeaderParent
|
||||
TechDraw::DrawLeaderLine *lead = nullptr;
|
||||
lead = dynamic_cast<TechDraw::DrawLeaderLine *>(myFeat);
|
||||
|
||||
if(lead) {
|
||||
App::DocumentObject* obj = lead->LeaderParent.getValue();
|
||||
if(obj != nullptr) {
|
||||
if (lead) {
|
||||
App::DocumentObject *obj = lead->LeaderParent.getValue();
|
||||
if (obj) {
|
||||
std::string parentName = obj->getNameInDocument();
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), parentName.c_str()) == 0) {
|
||||
for (std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if (strcmp((*it)->getViewName(), parentName.c_str()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@@ -626,9 +626,10 @@ void QGSPage::setPageTemplate(TechDraw::DrawTemplate *obj)
|
||||
{
|
||||
removeTemplate();
|
||||
|
||||
if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
|
||||
pageTemplate = new QGIDrawingTemplate(this);
|
||||
} else if(obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
||||
}
|
||||
else if (obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
||||
pageTemplate = new QGISVGTemplate(this);
|
||||
}
|
||||
pageTemplate->setTemplate(obj);
|
||||
|
||||
@@ -184,7 +184,7 @@ void TaskCenterLine::setUiPrimary()
|
||||
{
|
||||
setWindowTitle(QObject::tr("Create Center Line"));
|
||||
|
||||
if (m_partFeat != nullptr) {
|
||||
if (m_partFeat) {
|
||||
std::string baseName = m_partFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
for (auto& s: m_subNames) {
|
||||
@@ -213,7 +213,7 @@ void TaskCenterLine::setUiPrimary()
|
||||
void TaskCenterLine::setUiEdit()
|
||||
{
|
||||
setWindowTitle(QObject::tr("Edit Center Line"));
|
||||
if (m_partFeat != nullptr) {
|
||||
if (m_partFeat) {
|
||||
std::string baseName = m_partFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
QString listItem = Base::Tools::fromStdString(m_edgeName);
|
||||
@@ -322,7 +322,7 @@ void TaskCenterLine::createCenterLine(void)
|
||||
|
||||
if (cl == nullptr) { // try a horizontal line
|
||||
cl = CenterLine::CenterLineBuilder(m_partFeat, m_subNames, CenterLine::CLMODE::HORIZONTAL, false);
|
||||
if (cl != nullptr) {
|
||||
if (cl) {
|
||||
m_mode = CenterLine::CLMODE::HORIZONTAL;
|
||||
ui->rbHorizontal->blockSignals(true);
|
||||
ui->rbHorizontal->setChecked(true);
|
||||
@@ -385,7 +385,7 @@ void TaskCenterLine::updateOrientation(void)
|
||||
else if (orientation == CenterLine::CLMODE::HORIZONTAL)
|
||||
orientation = CenterLine::CLMODE::VERTICAL;
|
||||
cl = CenterLine::CenterLineBuilder(m_partFeat, m_subNames, orientation, m_cl->m_flip2Line);
|
||||
if (cl != nullptr) {
|
||||
if (cl) {
|
||||
if (orientation == CenterLine::CLMODE::VERTICAL) {
|
||||
m_cl->m_mode = CenterLine::CLMODE::VERTICAL;
|
||||
ui->rbVertical->blockSignals(true);
|
||||
@@ -404,7 +404,7 @@ void TaskCenterLine::updateOrientation(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (cl != nullptr) { // we succeeded
|
||||
if (cl) { // we succeeded
|
||||
// reset the flip for existing centerline that might use the flip feature (when created with FC 0.19)
|
||||
m_cl->m_flip2Line = false;
|
||||
m_partFeat->recomputeFeature();
|
||||
@@ -433,7 +433,7 @@ double TaskCenterLine::getCenterWidth()
|
||||
delete lg;
|
||||
Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat);
|
||||
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
|
||||
if ( partVP != nullptr ) {
|
||||
if (partVP) {
|
||||
width = partVP->IsoWidth.getValue();
|
||||
}
|
||||
return width;
|
||||
|
||||
@@ -130,7 +130,7 @@ void TaskCosVertex::setUiPrimary()
|
||||
// Base::Console().Message("TCV::setUiPrimary()\n");
|
||||
setWindowTitle(QObject::tr("New Cosmetic Vertex"));
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
std::string baseName = m_baseFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
}
|
||||
@@ -242,7 +242,7 @@ void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParen
|
||||
|
||||
DrawViewPart* dvp = m_baseFeat;
|
||||
DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
|
||||
if (dpgi != nullptr) {
|
||||
if (dpgi) {
|
||||
DrawProjGroup* dpg = dpgi->getPGroup();
|
||||
if (dpg == nullptr) {
|
||||
Base::Console().Message("TCV:onTrackerFinished - projection group is confused\n");
|
||||
@@ -275,8 +275,7 @@ void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParen
|
||||
void TaskCosVertex::removeTracker(void)
|
||||
{
|
||||
// Base::Console().Message("TCV::removeTracker()\n");
|
||||
if ((m_tracker != nullptr) &&
|
||||
(m_tracker->scene() != nullptr)) {
|
||||
if (m_tracker && m_tracker->scene()) {
|
||||
m_scene->removeItem(m_tracker);
|
||||
delete m_tracker;
|
||||
m_tracker = nullptr;
|
||||
@@ -285,7 +284,7 @@ void TaskCosVertex::removeTracker(void)
|
||||
|
||||
void TaskCosVertex::setEditCursor(QCursor c)
|
||||
{
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
QGIView* qgivBase = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
qgivBase->setCursor(c);
|
||||
}
|
||||
@@ -345,7 +344,7 @@ bool TaskCosVertex::reject()
|
||||
|
||||
removeTracker();
|
||||
m_trackerMode = QGTracker::TrackerMode::None;
|
||||
if (m_mdi != nullptr) {
|
||||
if (m_mdi) {
|
||||
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
|
||||
m_haveMdi = true;
|
||||
if (m_mdi) {
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
m_qgParent = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
}
|
||||
} else {
|
||||
@@ -214,7 +214,7 @@ void TaskRichAnno::setUiPrimary()
|
||||
enableVPUi(false);
|
||||
setWindowTitle(m_title);
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
std::string baseName = m_baseFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
}
|
||||
@@ -253,7 +253,7 @@ void TaskRichAnno::setUiEdit()
|
||||
setWindowTitle(m_title);
|
||||
enableTextUi(true);
|
||||
|
||||
if (m_annoFeat != nullptr) {
|
||||
if (m_annoFeat) {
|
||||
std::string baseName("None");
|
||||
App::DocumentObject* docObj = m_annoFeat->AnnoParent.getValue();
|
||||
if (docObj) {
|
||||
@@ -265,7 +265,7 @@ void TaskRichAnno::setUiEdit()
|
||||
ui->cbShowFrame->setChecked(m_annoFeat->ShowFrame.getValue());
|
||||
}
|
||||
|
||||
if (m_annoVP != nullptr) {
|
||||
if (m_annoVP) {
|
||||
ui->cpFrameColor->setColor(m_annoVP->LineColor.getValue().asValue<QColor>());
|
||||
ui->dsbWidth->setValue(m_annoVP->LineWidth.getValue());
|
||||
ui->cFrameStyle->setCurrentIndex(m_annoVP->LineStyle.getValue());
|
||||
@@ -347,7 +347,7 @@ void TaskRichAnno::createAnnoFeature()
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
|
||||
PageName.c_str(),annoName.c_str());
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.AnnoParent = App.activeDocument().%s",
|
||||
annoName.c_str(),m_baseFeat->getNameInDocument());
|
||||
}
|
||||
@@ -370,7 +370,7 @@ void TaskRichAnno::createAnnoFeature()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_annoFeat != nullptr) {
|
||||
if (m_annoFeat) {
|
||||
Gui::ViewProvider* vp = QGIView::getViewProvider(m_annoFeat);
|
||||
auto annoVP = dynamic_cast<ViewProviderRichAnno*>(vp);
|
||||
if (annoVP) {
|
||||
@@ -386,13 +386,13 @@ void TaskRichAnno::createAnnoFeature()
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
//trigger collectChildren in tree
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
m_baseFeat->touch();
|
||||
}
|
||||
|
||||
m_basePage->touch();
|
||||
|
||||
if (m_annoFeat != nullptr) {
|
||||
if (m_annoFeat) {
|
||||
m_annoFeat->requestPaint();
|
||||
}
|
||||
}
|
||||
@@ -467,7 +467,7 @@ QPointF TaskRichAnno::calcTextStartPos(double scale)
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> points;
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
if (m_baseFeat->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
TechDraw::DrawLeaderLine* dll = static_cast<TechDraw::DrawLeaderLine*>(m_baseFeat);
|
||||
points = dll->WayPoints.getValues();
|
||||
@@ -477,7 +477,7 @@ QPointF TaskRichAnno::calcTextStartPos(double scale)
|
||||
}
|
||||
} else {
|
||||
// Base::Console().Message("TRA::calcStartPos - no m_baseFeat\n");
|
||||
if (m_basePage != nullptr) {
|
||||
if (m_basePage) {
|
||||
double w = Rez::guiX(m_basePage->getPageWidth() / 2.0);
|
||||
double h = Rez::guiX(m_basePage->getPageHeight() / 2.0);
|
||||
return QPointF(w,h);
|
||||
@@ -551,7 +551,7 @@ bool TaskRichAnno::reject()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_basePage != nullptr) {
|
||||
if (m_basePage) {
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user