[TD] remove redundant nullptr checks
This commit is contained in:
@@ -74,7 +74,7 @@ CmdTechDrawStackGroup::CmdTechDrawStackGroup()
|
||||
void CmdTechDrawStackGroup::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;
|
||||
@@ -190,7 +190,7 @@ void CmdTechDrawStackTop::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;
|
||||
@@ -250,7 +250,7 @@ void CmdTechDrawStackBottom::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;
|
||||
@@ -310,7 +310,7 @@ void CmdTechDrawStackUp::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;
|
||||
@@ -370,7 +370,7 @@ void CmdTechDrawStackDown::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;
|
||||
|
||||
@@ -207,7 +207,7 @@ QPointF QGSPage::getTemplateCenter()
|
||||
{
|
||||
App::DocumentObject *obj = m_vpPage->getDrawPage()->Template.getValue();
|
||||
auto pageTemplate( dynamic_cast<TechDraw::DrawTemplate *>(obj) );
|
||||
if( pageTemplate != nullptr ) {
|
||||
if (pageTemplate) {
|
||||
double cx = Rez::guiX(pageTemplate->Width.getValue())/2.0;
|
||||
double cy = -Rez::guiX(pageTemplate->Height.getValue())/2.0;
|
||||
return QPointF(cx, cy);
|
||||
@@ -357,9 +357,8 @@ bool QGSPage::attachView(App::DocumentObject *obj)
|
||||
{
|
||||
// Base::Console().Message("QGSP::attachView(%s)\n", obj->getNameInDocument());
|
||||
QGIView* existing = findQViewForDocObj(obj);
|
||||
if (existing != nullptr) {
|
||||
if (existing)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto typeId(obj->getTypeId());
|
||||
|
||||
@@ -650,9 +649,8 @@ QGIView * QGSPage::addRichAnno(TechDraw::DrawRichAnno* richFeat)
|
||||
annoGroup->setViewFeature(richFeat);
|
||||
|
||||
QGIView *parent = findParent(annoGroup);
|
||||
if (parent != nullptr) {
|
||||
if (parent)
|
||||
addAnnoToParent(annoGroup, parent);
|
||||
}
|
||||
|
||||
annoGroup->updateView(true);
|
||||
|
||||
@@ -837,9 +835,9 @@ QGIView *QGSPage::findParent(QGIView *view) const
|
||||
TechDraw::DrawLeaderLine *lead = nullptr;
|
||||
lead = dynamic_cast<TechDraw::DrawLeaderLine *>(myFeat);
|
||||
|
||||
if(lead != nullptr) {
|
||||
if (lead) {
|
||||
App::DocumentObject* obj = lead->LeaderParent.getValue();
|
||||
if(obj != nullptr) {
|
||||
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) {
|
||||
@@ -851,9 +849,9 @@ QGIView *QGSPage::findParent(QGIView *view) const
|
||||
|
||||
//if type is a RichTextAnno we check AnnoParent
|
||||
TechDraw::DrawRichAnno* anno = dynamic_cast<TechDraw::DrawRichAnno*>(myFeat);
|
||||
if (anno != nullptr) {
|
||||
if (anno) {
|
||||
App::DocumentObject* obj = anno->AnnoParent.getValue();
|
||||
if (obj != nullptr) {
|
||||
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) {
|
||||
@@ -954,20 +952,18 @@ void QGSPage::fixOrphans(bool force)
|
||||
// if we ever have collections of collections, we'll need to revisit this
|
||||
TechDraw::DrawPage* thisPage = m_vpPage->getDrawPage();
|
||||
|
||||
if(!thisPage->getNameInDocument())
|
||||
if (!thisPage->getNameInDocument())
|
||||
return;
|
||||
|
||||
std::vector<App::DocumentObject*> pChildren = thisPage->getAllViews();
|
||||
|
||||
// if dv doesn't have a graphic, make one
|
||||
for (auto& dv: pChildren) {
|
||||
if (dv->isRemoving()) {
|
||||
if (dv->isRemoving())
|
||||
continue;
|
||||
}
|
||||
QGIView* qv = findQViewForDocObj(dv);
|
||||
if (qv == nullptr) {
|
||||
if (!qv)
|
||||
attachView(dv);
|
||||
}
|
||||
}
|
||||
// if qView doesn't have a Feature on this Page, delete it
|
||||
std::vector<QGIView*> qvss = getViews();
|
||||
|
||||
@@ -180,10 +180,8 @@ TechDraw::DrawViewImage* TaskActiveView::createActiveView()
|
||||
|
||||
App::DocumentObject* newObj = m_pageFeat->getDocument()->getObject(imageName.c_str());
|
||||
TechDraw::DrawViewImage* newImg = dynamic_cast<TechDraw::DrawViewImage*>(newObj);
|
||||
if ( (newObj == nullptr) ||
|
||||
(newImg == nullptr) ) {
|
||||
if (!newObj || !newImg)
|
||||
throw Base::RuntimeError("TaskActiveView - new image object not found");
|
||||
}
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(newImg->getDocument());
|
||||
if (guiDoc) {
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(newImg);
|
||||
|
||||
@@ -140,9 +140,8 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
|
||||
saveState();
|
||||
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
if (m_vpp->getMDIViewPage() != nullptr) {
|
||||
if (m_vpp->getMDIViewPage())
|
||||
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
//ctor for creation
|
||||
@@ -188,10 +187,8 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
ui->pbCancelEdit->setEnabled(false);
|
||||
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
if (m_vpp->getMDIViewPage() != nullptr) {
|
||||
if (m_vpp->getMDIViewPage())
|
||||
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TaskLeaderLine::saveState()
|
||||
@@ -238,7 +235,7 @@ void TaskLeaderLine::setUiPrimary()
|
||||
}
|
||||
|
||||
ui->pbTracker->setText(tr("Pick points"));
|
||||
if (m_vpp->getMDIViewPage() != nullptr) {
|
||||
if (m_vpp->getMDIViewPage()) {
|
||||
ui->pbTracker->setEnabled(true);
|
||||
ui->pbCancelEdit->setEnabled(true);
|
||||
} else {
|
||||
@@ -287,7 +284,7 @@ void TaskLeaderLine::setUiEdit()
|
||||
connect(ui->cboxEndSym, SIGNAL(currentIndexChanged(int)), this, SLOT(onEndSymbolChanged()));
|
||||
|
||||
ui->pbTracker->setText(tr("Edit points"));
|
||||
if (m_vpp->getMDIViewPage() != nullptr) {
|
||||
if (m_vpp->getMDIViewPage()) {
|
||||
ui->pbTracker->setEnabled(true);
|
||||
ui->pbCancelEdit->setEnabled(true);
|
||||
} else {
|
||||
@@ -471,7 +468,7 @@ void TaskLeaderLine::onTrackerClicked(bool clicked)
|
||||
Q_UNUSED(clicked);
|
||||
// Base::Console().Message("TTL::onTrackerClicked() m_pbTrackerState: %d\n",
|
||||
// m_pbTrackerState);
|
||||
if (m_vpp->getMDIViewPage() == nullptr) {
|
||||
if (!m_vpp->getMDIViewPage()) {
|
||||
Base::Console().Message("TLL::onTrackerClicked - no Mdi, no Tracker!\n");
|
||||
return;
|
||||
}
|
||||
@@ -569,12 +566,10 @@ void TaskLeaderLine::onTrackerClicked(bool clicked)
|
||||
void TaskLeaderLine::startTracker()
|
||||
{
|
||||
// Base::Console().Message("TTL::startTracker()\n");
|
||||
if (m_vpp->getQGSPage() == nullptr) {
|
||||
if (!m_vpp->getQGSPage())
|
||||
return;
|
||||
}
|
||||
if (m_trackerMode == QGTracker::TrackerMode::None) {
|
||||
if (m_trackerMode == QGTracker::TrackerMode::None)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_tracker) {
|
||||
m_tracker = new QGTracker(m_vpp->getQGSPage(), m_trackerMode);
|
||||
@@ -629,9 +624,8 @@ void TaskLeaderLine::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgPare
|
||||
void TaskLeaderLine::removeTracker()
|
||||
{
|
||||
// Base::Console().Message("TTL::removeTracker()\n");
|
||||
if (m_vpp->getQGSPage() == nullptr) {
|
||||
if (!m_vpp->getQGSPage())
|
||||
return;
|
||||
}
|
||||
if (m_tracker && m_tracker->scene()) {
|
||||
m_vpp->getQGSPage()->removeItem(m_tracker);
|
||||
delete m_tracker;
|
||||
@@ -783,9 +777,9 @@ bool TaskLeaderLine::accept()
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
if (m_vpp->getMDIViewPage() != nullptr) {
|
||||
if (m_vpp->getMDIViewPage())
|
||||
m_vpp->getMDIViewPage()->setContextMenuPolicy(m_saveContextPolicy);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ void TaskRichAnno::createAnnoFeature()
|
||||
if (obj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
m_annoFeat = static_cast<TechDraw::DrawRichAnno*>(obj);
|
||||
commonFeatureUpdate();
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat) {
|
||||
QPointF qTemp = calcTextStartPos(m_annoFeat->getScale());
|
||||
Base::Vector3d vTemp(qTemp.x(), qTemp.y());
|
||||
m_annoFeat->X.setValue(Rez::appX(vTemp.x));
|
||||
|
||||
@@ -244,9 +244,8 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
{
|
||||
// Base::Console().Message("VPDV::onGuiRepaint(%s) - this: %x\n", dv->getNameInDocument(), this);
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
|
||||
if (guiDoc == nullptr) {
|
||||
if (!guiDoc)
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<TechDraw::DrawPage*> pages = getViewObject()->findAllParentPages();
|
||||
if (pages.size() > 1) {
|
||||
|
||||
@@ -312,7 +312,7 @@ void ViewProviderPage::createMDIViewPage()
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument
|
||||
(pcObject->getDocument());
|
||||
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
|
||||
if (m_graphicsView == nullptr) {
|
||||
if (!m_graphicsView) {
|
||||
m_graphicsView = new QGVPage(this, m_graphicsScene, m_mdiView);
|
||||
std::string objName = m_pageName + "View";
|
||||
m_graphicsView->setObjectName(QString::fromLocal8Bit(objName.c_str()));
|
||||
@@ -339,9 +339,8 @@ void ViewProviderPage::removeMDIView(void)
|
||||
m_mdiView = nullptr; //m_mdiView will eventually be deleted and
|
||||
m_graphicsView = nullptr; //will take m_graphicsView with it
|
||||
Gui::MDIView* aw = Gui::getMainWindow()->activeWindow(); //WF: this bit should be in the remove window logic, not here.
|
||||
if (aw != nullptr) {
|
||||
if (aw)
|
||||
aw->showMaximized();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +134,8 @@ QGITemplate* ViewProviderTemplate::getQTemplate()
|
||||
auto page = dt->getParentPage();
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(dt->getDocument())->getViewProvider(page);
|
||||
TechDrawGui::ViewProviderPage* vpp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
if (vpp != nullptr) {
|
||||
if (vpp)
|
||||
return vpp->getQGSPage()->getTemplate();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user