[TD] Gui: remove some superfluous nullptr checks

This commit is contained in:
Uwe
2022-07-19 02:49:46 +02:00
parent 003757176c
commit 2e5e4dced8
38 changed files with 154 additions and 160 deletions

View File

@@ -299,8 +299,7 @@ private:
try {
if (PyObject_TypeCheck(docObj, &(App::DocumentPy::Type))) {
appDoc = static_cast<App::DocumentPy*>(docObj)->getDocumentPtr();
if ( (colorObj != nullptr) &&
PyTuple_Check(colorObj)) {
if (colorObj && PyTuple_Check(colorObj)) {
App::Color c = TechDraw::DrawUtil::pyTupleToColor(colorObj);
bgColor = c.asValue<QColor>();
}
@@ -341,13 +340,13 @@ private:
dynamic_cast<TechDrawGui::ViewProviderDrawingView*>(vp);
if (vpdv) {
qgiv = vpdv->getQView();
if (qgiv != nullptr) {
if (qgiv) {
Gui::PythonWrapper wrap;
if (!wrap.loadGuiModule()) {
throw Py::RuntimeError("Failed to load Python wrapper for Qt::Gui");
}
QGraphicsItem* item = wrap.toQGraphicsItem(qgiPy);
if (item != nullptr) {
if (item) {
qgiv->addArbitraryItem(item);
}
}
@@ -384,13 +383,13 @@ private:
dynamic_cast<TechDrawGui::ViewProviderDrawingView*>(vp);
if (vpdv) {
qgiv = vpdv->getQView();
if (qgiv != nullptr) {
if (qgiv) {
Gui::PythonWrapper wrap;
if (!wrap.loadGuiModule()) {
throw Py::RuntimeError("Failed to load Python wrapper for Qt::Gui");
}
QGraphicsObject* item = wrap.toQGraphicsObject(qgiPy);
if (item != nullptr) {
if (item) {
qgiv->addArbitraryItem(item);
}
}

View File

@@ -363,7 +363,7 @@ void CmdTechDrawView::activated(int iMsg)
//not a Link and not null. assume to be drawable. Undrawables will be
// skipped later.
shapes.push_back(obj);
if (partObj != nullptr) {
if (partObj) {
continue;
}
//don't know if this works for an XLink
@@ -642,7 +642,7 @@ void CmdTechDrawProjectionGroup::activated(int iMsg)
//not a Link and not null. assume to be drawable. Undrawables will be
// skipped later.
shapes.push_back(obj);
if (partObj != nullptr) {
if (partObj) {
continue;
}
for (auto& sub : sel.getSubNames()) {

View File

@@ -115,7 +115,7 @@ void CmdTechDrawLeaderLine::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;
@@ -176,7 +176,7 @@ void CmdTechDrawRichTextAnnotation::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;
@@ -228,7 +228,7 @@ void CmdTechDrawCosmeticVertexGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::CosmeticVertexGroup - 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;
@@ -417,7 +417,7 @@ void CmdTechDrawCosmeticVertex::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;
@@ -478,7 +478,7 @@ void CmdTechDrawMidpoints::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;
@@ -1201,8 +1201,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
std::string geomType = TechDraw::DrawUtil::getGeomTypeFromName(s);
if (geomType == "Edge") {
TechDraw::BaseGeomPtr bg = objFeat->getGeomByIndex(idx);
if ((bg != nullptr) &&
(bg->cosmetic) ) {
if (bg && bg->cosmetic) {
int source = bg->source();
std::string tag = bg->getCosmeticTag();
if (source == COSMETICEDGE) {
@@ -1382,7 +1381,7 @@ void CmdTechDrawShowAll::activated(int iMsg)
Gui::ViewProvider* vp = QGIView::getViewProvider(baseFeat);
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
if ( partVP != nullptr ) {
if (partVP) {
bool state = partVP->ShowAllEdges.getValue();
state = !state;
partVP->ShowAllEdges.setValue(state);

View File

@@ -1059,7 +1059,7 @@ void CmdTechDrawExtentGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtentGrp - 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;
@@ -1153,7 +1153,7 @@ void CmdTechDrawHorizontalExtentDimension::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;
@@ -1240,7 +1240,7 @@ void CmdTechDrawVerticalExtentDimension::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;

View File

@@ -261,7 +261,7 @@ void CmdTechDrawExtensionInsertPrefixGroup::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;
@@ -470,7 +470,7 @@ void CmdTechDrawExtensionIncreaseDecreaseGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionIncreaseDecreaseGroup - 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;
@@ -762,7 +762,7 @@ void CmdTechDrawExtensionPosChainDimensionGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionPosChainDimensionGroup - 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;
@@ -1090,7 +1090,7 @@ void CmdTechDrawExtensionCascadeDimensionGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - 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;
@@ -1429,7 +1429,7 @@ void CmdTechDrawExtensionCreateChainDimensionGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - 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;
@@ -1787,7 +1787,7 @@ void CmdTechDrawExtensionCreateCoordDimensionGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - 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;
@@ -2042,7 +2042,7 @@ void CmdTechDrawExtensionChamferDimensionGroup::activated(int iMsg)
{
// Base::Console().Message("CMD::ExtensionIncreaseDecreaseGroup - 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;

View File

@@ -181,7 +181,7 @@ bool DrawGuiUtil::isDraftObject(App::DocumentObject* obj)
bool result = false;
App::PropertyPythonObject* proxy = dynamic_cast<App::PropertyPythonObject*>(obj->getPropertyByName("Proxy"));
if (proxy != nullptr) {
if (proxy) {
//if no proxy, can not be Draft obj
//if has proxy, might be Draft obj
std::stringstream ss;
@@ -213,7 +213,7 @@ bool DrawGuiUtil::isArchObject(App::DocumentObject* obj)
bool result = false;
App::PropertyPythonObject* proxy = dynamic_cast<App::PropertyPythonObject*>(obj->getPropertyByName("Proxy"));
if (proxy != nullptr) {
if (proxy) {
//if no proxy, can not be Arch obj
//if has proxy, might be Arch obj
Py::Object proxyObj = proxy->getValue();
@@ -243,7 +243,7 @@ bool DrawGuiUtil::isArchSection(App::DocumentObject* obj)
bool result = false;
App::PropertyPythonObject* proxy = dynamic_cast<App::PropertyPythonObject*>(obj->getPropertyByName("Proxy"));
if (proxy != nullptr) {
if (proxy) {
//if no proxy, can not be Arch obj
//if has proxy, might be Arch obj
Py::Object proxyObj = proxy->getValue();

View File

@@ -210,13 +210,13 @@ void QGEPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QGEPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
QGIView *view = dynamic_cast<QGIView *> (parentItem());
assert(view != nullptr);
assert(view);
Q_UNUSED(view);
Q_EMIT hover(false);
QGraphicsItem* parent = parentItem();
bool parentSel(false);
if (parent != nullptr) {
if (parent) {
parentSel = parent->isSelected();
}
if (!parentSel && !isSelected()) {
@@ -291,10 +291,10 @@ void QGEPath::clearMarkers()
return;
}
for (auto& m: m_markers) {
if (m != nullptr) {
if (m) {
m->hide();
QGraphicsScene* s = m->scene();
if (s != nullptr) {
if (s) {
s->removeItem(m); //should this be setParentItem(nullptr) instead??
}
delete m;
@@ -335,7 +335,7 @@ void QGEPath::onDoubleClick(QPointF pos, int markerIndex)
void QGEPath::onEndEdit(void)
{
// Base::Console().Message("QGEPath::onEndEdit()\n");
if (m_ghost != nullptr) {
if (m_ghost) {
scene()->removeItem(m_ghost); //stop ghost from messing up brect
}
inEdit(false);

View File

@@ -99,7 +99,7 @@ QGIRichAnno::QGIRichAnno(QGraphicsItem* myParent,
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
if (myParent != nullptr) {
if (myParent) {
setParentItem(myParent);
}

View File

@@ -141,9 +141,9 @@ void QGIView::onSourceChange(TechDraw::DrawView* newParent)
void QGIView::isVisible(bool state)
{
auto feat = getViewObject();
if (feat != nullptr) {
if (feat) {
auto vp = QGIView::getViewProvider(feat);
if (vp != nullptr) {
if (vp) {
Gui::ViewProviderDocumentObject* vpdo = dynamic_cast<Gui::ViewProviderDocumentObject*>(vp);
if (vpdo != nullptr) {
vpdo->Visibility.setValue(state);
@@ -156,9 +156,9 @@ bool QGIView::isVisible(void)
{
bool result = false;
auto feat = getViewObject();
if (feat != nullptr) {
if (feat) {
auto vp = QGIView::getViewProvider(feat);
if (vp != nullptr) {
if (vp) {
Gui::ViewProviderDocumentObject* vpdo = dynamic_cast<Gui::ViewProviderDocumentObject*>(vp);
if (vpdo != nullptr) {
result = vpdo->Visibility.getValue();
@@ -198,7 +198,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
if (getViewObject()->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
TechDraw::DrawProjGroupItem* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(getViewObject());
TechDraw::DrawProjGroup* dpg = dpgi->getPGroup();
if (dpg != nullptr) {
if (dpg) {
if(alignHash.size() == 1) { //if aligned.
QGraphicsItem* item = alignHash.begin().value();
QString alignMode = alignHash.begin().key();
@@ -377,7 +377,7 @@ double QGIView::getScale()
{
double result = 1.0;
TechDraw::DrawView* feat = getViewObject();
if (feat != nullptr) {
if (feat) {
result = feat->getScale();
}
return result;
@@ -422,7 +422,7 @@ void QGIView::draw()
{
// Base::Console().Message("QGIV::draw()\n");
double xFeat, yFeat;
if (getViewObject() != nullptr) {
if (getViewObject()) {
xFeat = Rez::guiX(getViewObject()->X.getValue());
yFeat = Rez::guiX(getViewObject()->Y.getValue());
if (!getViewObject()->LockPosition.getValue()) {
@@ -608,7 +608,7 @@ QGIView* QGIView::getQGIVByName(std::string name)
Gui::ViewProvider* QGIView::getViewProvider(App::DocumentObject* obj)
{
Gui::ViewProvider* result = nullptr;
if (obj != nullptr) {
if (obj) {
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(obj->getDocument());
result = guiDoc->getViewProvider(obj);
}
@@ -622,7 +622,7 @@ QGVPage* QGIView::getGraphicsView(TechDraw::DrawView* dv)
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(vp);
if (vpdv != nullptr) {
MDIViewPage* mdi = vpdv->getMDIViewPage();
if (mdi != nullptr) {
if (mdi) {
graphicsView = mdi->getQGVPage();
}
}
@@ -636,7 +636,7 @@ QGSPage* QGIView::getGraphicsScene(TechDraw::DrawView* dv)
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(vp);
if (vpdv != nullptr) {
MDIViewPage* mdi = vpdv->getMDIViewPage();
if (mdi != nullptr) {
if (mdi) {
graphicsScene = mdi->getQGSPage();
}
}
@@ -652,8 +652,7 @@ MDIViewPage* QGIView::getMDIViewPage(void) const
//remove a child of this from scene while keeping scene indexes valid
void QGIView::removeChild(QGIView* child)
{
if ( (child != nullptr) &&
(child->parentItem() == this) ) {
if (child && (child->parentItem() == this) ) {
prepareGeometryChange();
scene()->removeItem(child);
}
@@ -664,13 +663,13 @@ bool QGIView::getFrameState(void)
// Base::Console().Message("QGIV::getFrameState() - %s\n",getViewName());
bool result = true;
TechDraw::DrawView* dv = getViewObject();
if (dv != nullptr) {
if (dv) {
TechDraw::DrawPage* page = dv->findParentPage();
if (page != nullptr) {
if (page) {
Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument());
Gui::ViewProvider* vp = activeGui->getViewProvider(page);
ViewProviderPage* vpp = dynamic_cast<ViewProviderPage*>(vp);
if (vpp != nullptr) {
if (vpp) {
result = vpp->getFrameState();
}
}
@@ -680,7 +679,7 @@ bool QGIView::getFrameState(void)
void QGIView::addArbitraryItem(QGraphicsItem* qgi)
{
if (qgi != nullptr) {
if (qgi) {
// m_randomItems.push_back(qgi);
addToGroup(qgi);
qgi->show();

View File

@@ -183,7 +183,7 @@ void QGIBalloonLabel::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QGIBalloonLabel::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
QGIView *view = dynamic_cast<QGIView *> (parentItem());
assert(view != nullptr);
assert(view);
Q_UNUSED(view);
Q_EMIT hover(false);

View File

@@ -2373,7 +2373,7 @@ QColor QGIViewDimension::prefNormalColor()
// auto dim( dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject()) );
TechDraw::DrawViewDimension* dim = nullptr;
TechDraw::DrawView* dv = getViewObject();
if (dv != nullptr) {
if (dv) {
dim = dynamic_cast<TechDraw::DrawViewDimension*>(dv);
if( dim == nullptr ) {
return m_colNormal;
@@ -2384,7 +2384,7 @@ QColor QGIViewDimension::prefNormalColor()
ViewProviderDimension* vpDim = nullptr;
Gui::ViewProvider* vp = getViewProvider(dim);
if ( vp != nullptr ) {
if (vp) {
vpDim = dynamic_cast<ViewProviderDimension*>(vp);
if (vpDim == nullptr) {
return m_colNormal;

View File

@@ -496,7 +496,7 @@ void QGIViewPart::drawViewPart()
newFace->setHatchFile(fGeom->PatIncluded.getValue());
Gui::ViewProvider* gvp = QGIView::getViewProvider(fGeom);
ViewProviderGeomHatch* geomVp = dynamic_cast<ViewProviderGeomHatch*>(gvp);
if (geomVp != nullptr) {
if (geomVp) {
newFace->setHatchColor(geomVp->ColorPattern.getValue());
newFace->setLineWeight(geomVp->WeightPattern.getValue());
}
@@ -515,7 +515,7 @@ void QGIViewPart::drawViewPart()
newFace->setHatchFile(fHatch->SvgIncluded.getValue());
Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch);
ViewProviderHatch* hatchVp = dynamic_cast<ViewProviderHatch*>(gvp);
if (hatchVp != nullptr) {
if (hatchVp) {
double hatchScale = hatchVp->HatchScale.getValue();
if (hatchScale > 0.0) {
newFace->setHatchScale(hatchVp->HatchScale.getValue());
@@ -582,7 +582,7 @@ void QGIViewPart::drawViewPart()
}
} else {
TechDraw::GeomFormat* gf = viewPart->getGeomFormatBySelection(i);
if (gf != nullptr) {
if (gf) {
item->setNormalColor(gf->m_format.m_color.asValue<QColor>());
item->setWidth(gf->m_format.m_weight * lineScaleFactor);
item->setStyle(gf->m_format.m_style);
@@ -662,7 +662,7 @@ void QGIViewPart::drawViewPart()
QGIVertex *item = new QGIVertex(i);
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexBySelection(i);
// TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByGeom(i);
if (cv != nullptr) {
if (cv) {
item->setNormalColor(cv->color.asValue<QColor>());
item->setRadius(Rez::guiX(cv->size));
} else {
@@ -691,7 +691,7 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
bool result = true;
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
TechDraw::CosmeticEdge* ce = partFeat ? partFeat->getCosmeticEdge(cTag) : nullptr;
if (ce != nullptr) {
if (ce) {
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
item->setStyle(ce->m_format.m_style);
@@ -707,7 +707,7 @@ bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
bool result = true;
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr;
if (cl != nullptr) {
if (cl) {
item->setNormalColor(cl->m_format.m_color.asValue<QColor>());
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
item->setStyle(cl->m_format.m_style);
@@ -773,7 +773,7 @@ void QGIViewPart::removePrimitives()
{
QList<QGraphicsItem*> children = childItems();
MDIViewPage* mdi = getMDIViewPage();
if (mdi != nullptr) {
if (mdi) {
getMDIViewPage()->blockSceneSelection(true);
}
for (auto& c:children) {
@@ -784,7 +784,7 @@ void QGIViewPart::removePrimitives()
delete prim;
}
}
if (mdi != nullptr) {
if (mdi) {
getMDIViewPage()->blockSceneSelection(false);
}
}

View File

@@ -171,11 +171,11 @@ void QGIWeldSymbol::draw()
removeQGITiles();
if (m_arrowFeat != nullptr) {
if (m_arrowFeat) {
drawTile(m_arrowFeat);
}
if (m_otherFeat != nullptr) {
if (m_otherFeat) {
drawTile(m_otherFeat);
}

View File

@@ -59,7 +59,7 @@ QGTracker::QGTracker(QGSPage* inScene, TrackerMode m):
m_lastClick(QPointF(FLT_MAX,FLT_MAX))
{
setTrackerMode(m);
if (inScene != nullptr) {
if (inScene) {
inScene->addItem(this);
} else {
throw Base::ValueError("QGT::QGT() - passed scene is NULL\n");
@@ -321,13 +321,13 @@ void QGTracker::getPickedQGIV(QPointF pos)
QGraphicsView* ourView = views.front(); //only 1 view / 1 scene / 1 mdipage
QTransform viewXForm = ourView->transform();
QGraphicsItem* pickedItem = scene()->itemAt(pos,viewXForm);
if (pickedItem != nullptr) {
if (pickedItem) {
QGraphicsItem* topItem = pickedItem->topLevelItem();
if (topItem != pickedItem) {
pickedItem = topItem;
} //pickedItem sb a QGIV
QGIView* qgParent = dynamic_cast<QGIView*>(pickedItem);
if (qgParent != nullptr) {
if (qgParent) {
m_qgParent = qgParent;
}
}

View File

@@ -85,7 +85,7 @@ void QGVNavStyle::initialize()
void QGVNavStyle::setAnchor()
{
if (m_viewer != nullptr) {
if (m_viewer) {
if (zoomAtCursor) {
m_viewer->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
m_viewer->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);

View File

@@ -113,7 +113,7 @@ void QGVNavStyleTouchpad::handleMouseMoveEvent(QMouseEvent *event)
void QGVNavStyleTouchpad::setAnchor()
{
//this navigation style can not anchor under mouse since mouse is moving as part of zoom action
if (m_viewer != nullptr) {
if (m_viewer) {
m_viewer->setResizeAnchor(QGraphicsView::AnchorViewCenter);
m_viewer->setTransformationAnchor(QGraphicsView::AnchorViewCenter);
}

View File

@@ -299,7 +299,7 @@ void QGVPage::initNavigationStyle()
void QGVPage::setNavigationStyle(std::string navParm)
{
// Base::Console().Message("QGVP::setNavigationStyle(%s)\n", navParm.c_str());
if (m_navStyle != nullptr) {
if (m_navStyle) {
delete m_navStyle;
}
@@ -451,7 +451,7 @@ void QGVPage::contextMenuEvent(QContextMenuEvent *event)
//delete the old saved event before creating a new one to avoid memory leak
//NOTE: saving the actual event doesn't work as the event gets deleted somewhere in Qt
if (m_saveContextEvent != nullptr) {
if (m_saveContextEvent) {
delete m_saveContextEvent;
}
m_saveContextEvent = new QContextMenuEvent(QContextMenuEvent::Mouse,
@@ -461,7 +461,7 @@ void QGVPage::contextMenuEvent(QContextMenuEvent *event)
void QGVPage::pseudoContextEvent()
{
if (m_saveContextEvent != nullptr) {
if (m_saveContextEvent) {
m_parentMDI->contextMenuEvent(m_saveContextEvent);
}
}

View File

@@ -95,7 +95,7 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP)
// negative kink length is allowed, thus no minimum
ui->qsbKinkLength->setUnit(Base::Unit::Length);
if (balloonVP != nullptr) {
if (balloonVP) {
ui->textColor->setColor(balloonVP->Color.getValue().asValue<QColor>());
connect(ui->textColor, SIGNAL(changed()), this, SLOT(onColorChanged()));
ui->qsbFontSize->setValue(balloonVP->Fontsize.getValue());

View File

@@ -117,7 +117,7 @@ TaskCosmeticLine::TaskCosmeticLine(TechDraw::DrawViewPart* partFeat,
TaskCosmeticLine::~TaskCosmeticLine()
{
if (m_saveCE != nullptr) {
if (m_saveCE) {
delete m_saveCE;
}
}

View File

@@ -184,13 +184,13 @@ TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat):
m_detailName = m_detailFeat->getNameInDocument();
m_basePage = m_detailFeat->findParentPage();
if (m_basePage != nullptr) {
if (m_basePage) {
m_pageName = m_basePage->getNameInDocument();
}
App::DocumentObject* baseObj = m_detailFeat->BaseView.getValue();
m_baseFeat = dynamic_cast<TechDraw::DrawViewPart*>(baseObj);
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
m_baseName = m_baseFeat->getNameInDocument();
} else {
Base::Console().Error("TaskDetail - no BaseView. Can not proceed.\n");
@@ -276,7 +276,7 @@ void TaskDetail::restoreDetailState()
void TaskDetail::setUiFromFeat()
{
// Base::Console().Message("TD::setUIFromFeat()\n");
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
std::string baseName = getBaseFeat()->getNameInDocument();
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
}
@@ -357,7 +357,7 @@ void TaskDetail::onScaleTypeEdit()
ui->qsbScale->setEnabled(false);
detailFeat->ScaleType.setValue(0.0);
// set the page scale if there is a valid page
if (m_basePage != nullptr) {
if (m_basePage) {
// set the page scale
detailFeat->Scale.setValue(m_basePage->Scale.getValue());
ui->qsbScale->setValue(m_basePage->Scale.getValue());
@@ -429,7 +429,7 @@ void TaskDetail::onHighlightMoved(QPointF dragEnd)
DrawViewPart* dvp = getBaseFeat();
DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
if (dpgi != nullptr) {
if (dpgi) {
DrawProjGroup* dpg = dpgi->getPGroup();
if (dpg == nullptr) {
Base::Console().Message("TD::getAnchorScene - projection group is confused\n");
@@ -576,9 +576,9 @@ DrawViewPart* TaskDetail::getBaseFeat()
{
// Base::Console().Message("TD::getBaseFeat()\n");
if (m_doc != nullptr) {
if (m_doc) {
App::DocumentObject* baseObj = m_doc->getObject(m_baseName.c_str());
if (baseObj != nullptr) {
if (baseObj) {
return static_cast<DrawViewPart*>(baseObj);
}
}
@@ -595,9 +595,9 @@ DrawViewDetail* TaskDetail::getDetailFeat()
{
// Base::Console().Message("TD::getDetailFeat()\n");
if (m_doc != nullptr) {
if (m_doc) {
App::DocumentObject* detailObj = m_doc->getObject(m_detailName.c_str());
if (detailObj != nullptr) {
if (detailObj) {
return static_cast<DrawViewDetail*>(detailObj);
}
}

View File

@@ -119,7 +119,7 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di
connect(ui->cbArbitraryTolerances, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryTolerancesChanged()));
// Display Style
if (dimensionVP != nullptr) {
if (dimensionVP) {
ui->cbArrowheads->setChecked(dimensionVP->FlipArrowheads.getValue());
connect(ui->cbArrowheads, SIGNAL(stateChanged(int)), this, SLOT(onFlipArrowheadsChanged()));
ui->dimensionColor->setColor(dimensionVP->Color.getValue().asValue<QColor>());

View File

@@ -127,7 +127,7 @@ void TaskHatch::saveHatchState()
void TaskHatch::restoreHatchState()
{
// Base::Console().Message("TH::restoreHatchState()\n");
if (m_hatch != nullptr) {
if (m_hatch) {
m_hatch->HatchPattern.setValue(m_saveFile);
m_vp->HatchScale.setValue(m_saveScale);
m_vp->HatchColor.setValue(m_saveColor);
@@ -156,14 +156,14 @@ void TaskHatch::apply(bool forceUpdate)
{
Q_UNUSED(forceUpdate)
// Base::Console().Message("TH::apply() - m_hatch: %X\n", m_hatch);
if (m_hatch == nullptr) {
if (!m_hatch) {
createHatch();
}
if (m_hatch != nullptr) {
if (m_hatch) {
updateHatch();
}
if (m_dvp != nullptr) {
if (m_dvp) {
//only need requestPaint to hatch the face
// m_dvp->requestPaint();
//need a recompute in order to claimChildren in tree

View File

@@ -108,7 +108,7 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
return;
}
App::DocumentObject* obj = m_lineFeat->LeaderParent.getValue();
if (obj != nullptr) {
if (obj) {
if (obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()) ) {
m_baseFeat = static_cast<TechDraw::DrawView*>(m_lineFeat->LeaderParent.getValue());
}
@@ -121,10 +121,10 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
m_qgParent = nullptr;
m_haveMdi = true;
m_mdi = vpp->getMDIViewPage();
if (m_mdi != nullptr) {
if (m_mdi) {
m_scene = m_mdi->getQGSPage();
m_view = m_mdi->getQGVPage();
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
m_qgParent = m_scene->findQViewForDocObj(m_baseFeat);
}
} else {
@@ -197,10 +197,10 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
m_qgParent = nullptr;
m_haveMdi = true;
m_mdi = vpp->getMDIViewPage();
if (m_mdi != nullptr) {
if (m_mdi) {
m_scene = m_mdi->getQGSPage();
m_view = m_mdi->getQGVPage();
if (baseFeat != nullptr) {
if (baseFeat) {
m_qgParent = m_scene->findQViewForDocObj(baseFeat);
}
} else {
@@ -230,7 +230,7 @@ TaskLeaderLine::~TaskLeaderLine()
void TaskLeaderLine::saveState()
{
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
m_savePoints = m_lineFeat->WayPoints.getValues();
m_saveX = m_lineFeat->X.getValue();
m_saveY = m_lineFeat->Y.getValue();
@@ -239,7 +239,7 @@ void TaskLeaderLine::saveState()
void TaskLeaderLine::restoreState()
{
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
m_lineFeat->WayPoints.setValues(m_savePoints);
m_lineFeat->X.setValue(m_saveX);
m_lineFeat->Y.setValue(m_saveY);
@@ -266,7 +266,7 @@ void TaskLeaderLine::setUiPrimary()
enableVPUi(true);
setWindowTitle(QObject::tr("New Leader Line"));
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
std::string baseName = m_baseFeat->getNameInDocument();
ui->tbBaseView->setText(Base::Tools::fromStdString(baseName));
}
@@ -309,7 +309,7 @@ void TaskLeaderLine::setUiEdit()
enableVPUi(true);
setWindowTitle(QObject::tr("Edit Leader Line"));
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
std::string baseName = m_lineFeat->LeaderParent.getValue()->getNameInDocument();
ui->tbBaseView->setText(Base::Tools::fromStdString(baseName));
@@ -330,7 +330,7 @@ void TaskLeaderLine::setUiEdit()
}
}
if (m_lineVP != nullptr) {
if (m_lineVP) {
ui->cpLineColor->setColor(m_lineVP->Color.getValue().asValue<QColor>());
ui->dsbWeight->setValue(m_lineVP->LineWidth.getValue());
ui->cboxStyle->setCurrentIndex(m_lineVP->LineStyle.getValue());
@@ -395,7 +395,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
m_leaderType.c_str(),m_leaderName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
PageName.c_str(),m_leaderName.c_str());
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
Command::doCommand(Command::Doc,"App.activeDocument().%s.LeaderParent = App.activeDocument().%s",
m_leaderName.c_str(),m_baseFeat->getNameInDocument());
}
@@ -416,10 +416,10 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
commonFeatureUpdate();
}
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_lineFeat);
auto leadVP = dynamic_cast<ViewProviderLeader*>(vp);
if ( leadVP != nullptr ) {
if (leadVP) {
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
leadVP->Color.setValue(ac);
@@ -432,13 +432,13 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
Gui::Command::commitCommand();
//trigger claimChildren in tree
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
m_baseFeat->touch();
}
m_basePage->touch();
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
m_lineFeat->requestPaint();
}
}
@@ -458,7 +458,7 @@ void TaskLeaderLine::updateLeaderFeature(void)
Gui::Command::updateActive();
Gui::Command::commitCommand();
if (m_baseFeat != nullptr) {
if (m_baseFeat) {
m_baseFeat->requestPaint();
}
m_lineFeat->requestPaint();
@@ -513,7 +513,7 @@ void TaskLeaderLine::onTrackerClicked(bool b)
if ( (m_pbTrackerState == TRACKERSAVE) &&
(getCreateMode()) ){
if (m_tracker != nullptr) {
if (m_tracker) {
m_tracker->terminateDrawing();
}
m_pbTrackerState = TRACKERPICK;
@@ -525,7 +525,7 @@ void TaskLeaderLine::onTrackerClicked(bool b)
return;
} else if ( (m_pbTrackerState == TRACKERSAVE) &&
(!getCreateMode()) ) { //edit mode
if (m_qgLine != nullptr) {
if (m_qgLine) {
m_qgLine->closeEdit();
}
m_pbTrackerState = TRACKERPICK;
@@ -638,7 +638,7 @@ void TaskLeaderLine::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgPare
return;
}
if (m_qgParent != nullptr) {
if (m_qgParent) {
double scale = m_qgParent->getScale();
QPointF mapped = m_qgParent->mapFromScene(pts.front()) / scale;
m_attachPoint = Base::Vector3d(mapped.x(), mapped.y(), 0.0);
@@ -668,8 +668,7 @@ void TaskLeaderLine::removeTracker(void)
if (!m_haveMdi) {
return;
}
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;
@@ -682,7 +681,7 @@ void TaskLeaderLine::onCancelEditClicked(bool b)
// Base::Console().Message("TTL::onCancelEditClicked() m_pbTrackerState: %d\n",
// m_pbTrackerState);
abandonEditSession();
if (m_lineFeat != nullptr) {
if (m_lineFeat) {
m_lineFeat->requestPaint();
}
@@ -746,7 +745,7 @@ void TaskLeaderLine::onPointEditComplete(void)
void TaskLeaderLine::abandonEditSession(void)
{
// Base::Console().Message("TTL::abandonEditSession()\n");
if (m_qgLine != nullptr) {
if (m_qgLine) {
m_qgLine->abandonEdit();
}
QString msg = tr("In progress edit abandoned. Start over.");
@@ -842,8 +841,7 @@ bool TaskLeaderLine::reject()
if (!doc)
return false;
if (getCreateMode() &&
(m_lineFeat != nullptr) ) {
if (getCreateMode() && m_lineFeat) {
removeFeature();
}
else {
@@ -857,7 +855,7 @@ bool TaskLeaderLine::reject()
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
if (m_mdi != nullptr) {
if (m_mdi) {
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
}

View File

@@ -116,7 +116,7 @@ void TaskLineDecor::getDefaults(void)
if (!m_edges.empty()) {
int num = DrawUtil::getIndexFromName(m_edges.front());
BaseGeomPtr bg = m_partFeat->getGeomByIndex(num);
if (bg != nullptr) {
if (bg) {
if (bg->cosmetic) {
if (bg->source() == 1) {
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeBySelection(m_edges.front());
@@ -134,7 +134,7 @@ void TaskLineDecor::getDefaults(void)
}
} else {
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatBySelection(num);
if (gf != nullptr) {
if (gf) {
m_style = gf->m_format.m_style;
m_color = gf->m_format.m_color;
m_weight = gf->m_format.m_weight;
@@ -142,7 +142,7 @@ void TaskLineDecor::getDefaults(void)
} else {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat);
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
if ( partVP != nullptr ) {
if (partVP) {
m_weight = partVP->LineWidth.getValue();
m_style = Qt::SolidLine; // = 1
m_color = LineFormat::getDefEdgeColor();
@@ -188,7 +188,7 @@ void TaskLineDecor::applyDecorations(void)
for (auto& e: m_edges) {
int num = DrawUtil::getIndexFromName(e);
BaseGeomPtr bg = m_partFeat->getGeomByIndex(num);
if (bg != nullptr) {
if (bg) {
if (bg->cosmetic) {
if (bg->source() == 1) {
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeBySelection(e);
@@ -206,7 +206,7 @@ void TaskLineDecor::applyDecorations(void)
}
} else {
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatBySelection(num);
if (gf != nullptr) {
if (gf) {
gf->m_format.m_style = m_style;
gf->m_format.m_color = m_color;
gf->m_format.m_weight = m_weight;
@@ -446,7 +446,7 @@ TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
}
TaskLineDecor* parent = dynamic_cast<TaskLineDecor*>(widget);
if (parent != nullptr) {
if (parent) {
restore = new TaskRestoreLines(partFeat, parent);
restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_DecorateLine"),
tr("Restore Invisible Lines"), true, nullptr);

View File

@@ -160,7 +160,7 @@ void TaskProjGroup::saveGroupState()
for( const auto it : multiView->Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if (view != nullptr) {
if (view) {
m_saveViewNames.push_back(view->Type.getValueAsString());
}
}
@@ -441,7 +441,7 @@ const char * TaskProjGroup::viewChkIndexToCStr(int index)
// First Angle: FBRight B FBL
// Right F L Rear
// FTRight T FTL
assert (multiView != nullptr);
assert (multiView);
bool thirdAngle = multiView->usedProjectionType().isValue("Third Angle");
switch(index) {
@@ -484,7 +484,7 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections)
}
const char *viewStr = viewChkIndexToCStr(i);
if ( viewStr != nullptr && multiView->hasProjection(viewStr) ) {
if (viewStr && multiView->hasProjection(viewStr)) {
box->setCheckState(Qt::Checked);
} else {
box->setCheckState(Qt::Unchecked);

View File

@@ -107,7 +107,7 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
//m_baseFeat can be null
App::DocumentObject* obj = m_annoFeat->AnnoParent.getValue();
if (obj != nullptr) {
if (obj) {
if ( obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()) ) {
m_baseFeat = static_cast<TechDraw::DrawView*>(m_annoFeat->AnnoParent.getValue());
}
@@ -120,7 +120,7 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
m_mdi = dvp->getMDIViewPage();
m_qgParent = nullptr;
m_haveMdi = true;
if (m_mdi != nullptr) {
if (m_mdi) {
m_scene = m_mdi->getQGSPage();
if (m_baseFeat != nullptr) {
m_qgParent = m_scene->findQViewForDocObj(m_baseFeat);
@@ -175,7 +175,7 @@ TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat,
m_qgParent = nullptr;
m_haveMdi = true;
m_mdi = dvp->getMDIViewPage();
if (m_mdi != nullptr) {
if (m_mdi) {
m_scene= m_mdi->getQGSPage();
m_qgParent = m_scene->findQViewForDocObj(baseFeat);
} else {
@@ -256,7 +256,7 @@ void TaskRichAnno::setUiEdit()
if (m_annoFeat != nullptr) {
std::string baseName("None");
App::DocumentObject* docObj = m_annoFeat->AnnoParent.getValue();
if (docObj != nullptr) {
if (docObj) {
baseName = docObj->getNameInDocument();
}
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
@@ -373,7 +373,7 @@ void TaskRichAnno::createAnnoFeature()
if (m_annoFeat != nullptr) {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_annoFeat);
auto annoVP = dynamic_cast<ViewProviderRichAnno*>(vp);
if (annoVP != nullptr) {
if (annoVP) {
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());
annoVP->LineColor.setValue(ac);
@@ -556,8 +556,7 @@ bool TaskRichAnno::reject()
if (!doc) {
return false;
}
if (getCreateMode() &&
(m_annoFeat != nullptr) ) {
if (getCreateMode() && m_annoFeat) {
removeFeature();
}
}

View File

@@ -466,7 +466,7 @@ void TaskSectionView::updateSectionView(void)
}
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit SectionView"));
if (m_section != nullptr) {
if (m_section) {
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.SectionDirection = '%s'",
m_sectionName.c_str(),m_dirName.c_str());
Command::doCommand(Command::Doc,

View File

@@ -225,7 +225,7 @@ void TaskWeldingSymbol::setUiEdit()
ui->leTailText->setText(QString::fromUtf8(m_weldFeat->TailText.getValue()));
getTileFeats();
if (m_arrowFeat != nullptr) {
if (m_arrowFeat) {
QString qTemp = QString::fromUtf8(m_arrowFeat->LeftText.getValue());
ui->leArrowTextL->setText(qTemp);
qTemp = QString::fromUtf8(m_arrowFeat->RightText.getValue());
@@ -247,7 +247,7 @@ void TaskWeldingSymbol::setUiEdit()
}
}
if (m_otherFeat != nullptr) {
if (m_otherFeat) {
QString qTemp = QString::fromUtf8(m_otherFeat->LeftText.getValue());
ui->leOtherTextL->setText(qTemp);
qTemp = QString::fromUtf8(m_otherFeat->RightText.getValue());

View File

@@ -209,7 +209,7 @@ void ViewProviderDimension::onChanged(const App::Property* p)
QGIView* qgiv = getQView();
if (qgiv) {
QGIViewDimension* qgivd = dynamic_cast<QGIViewDimension*>(qgiv);
if (qgivd != nullptr) {
if (qgivd) {
qgivd->setNormalColorAll();
}
}

View File

@@ -73,7 +73,7 @@ void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat)
auto bnd = boost::bind(&ViewProviderDrawingView::onGuiRepaint, this, bp::_1);
auto feature = getViewObject();
if (feature != nullptr) {
if (feature) {
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
//TODO: would be good to start the QGIV creation process here, but no guarantee we actually have
// MDIVP or QGVP yet.
@@ -150,7 +150,7 @@ void ViewProviderDrawingView::hide(void)
// in FC Tree hiding does not change selection state.
// block/unblock selection protects against crash in Gui::SelectionSingleton::setVisible
MDIViewPage* mdi = getMDIViewPage();
if (mdi != nullptr) { //if there is no mdivp, there is nothing to hide!
if (mdi) { //if there is no mdivp, there is nothing to hide!
mdi->blockSceneSelection(true);
qView->hide();
ViewProviderDocumentObject::hide();
@@ -167,7 +167,7 @@ QGIView* ViewProviderDrawingView::getQView(void)
TechDraw::DrawView* dv = getViewObject();
if (dv) {
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
if (guiDoc != nullptr) {
if (guiDoc) {
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
@@ -234,7 +234,7 @@ MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
{
MDIViewPage* result = nullptr;
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
if (guiDoc != nullptr) {
if (guiDoc) {
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
@@ -265,12 +265,12 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
//view v belongs to this page p
Gui::ViewProvider* vp = guiDoc->getViewProvider(p);
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
if (vpPage != nullptr) {
if (vpPage->getMDIViewPage() != nullptr) {
if (vpPage) {
if (vpPage->getMDIViewPage()) {
if (vpPage->getMDIViewPage()->getQGSPage()) {
QGIView* qView = dynamic_cast<QGIView *>(vpPage->getMDIViewPage()->
getQGSPage()->findQViewForDocObj(v));
if (qView != nullptr) {
if (qView) {
qView->updateView(true);
}
}
@@ -293,7 +293,7 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
// via the parent DrawPage since the DP is created before any views.
// Base::Console().Message("VPDV::onGuiRepaint - no QGIV for: %s\n",dv->getNameInDocument());
MDIViewPage* page = getMDIViewPage();
if (page != nullptr) {
if (page) {
page->addView(dv);
}
}

View File

@@ -133,7 +133,7 @@ void ViewProviderGeomHatch::onChanged(const App::Property* p)
if ((p == &WeightPattern) ||
(p == &ColorPattern) ) {
auto gHatch = getViewObject();
if (gHatch != nullptr) {
if (gHatch) {
TechDraw::DrawViewPart* parent = gHatch->getSourceView();
if (parent) {
parent->requestPaint();

View File

@@ -121,7 +121,7 @@ void ViewProviderLeader::updateData(const App::Property* p)
if (p == &getFeature()->LeaderParent) {
App::DocumentObject* docObj = getFeature()->LeaderParent.getValue();
TechDraw::DrawView* dv = dynamic_cast<TechDraw::DrawView*>(docObj);
if (dv != nullptr) {
if (dv) {
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->onSourceChange(dv);

View File

@@ -107,7 +107,7 @@ void ViewProviderPage::attach(App::DocumentObject *pcFeat)
auto bnd = boost::bind(&ViewProviderPage::onGuiRepaint, this, bp::_1);
auto feature = getDrawPage();
if (feature != nullptr) {
if (feature) {
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
m_pageName = feature->getNameInDocument();
} else {
@@ -260,7 +260,7 @@ bool ViewProviderPage::setEdit(int ModNum)
return false; //finished editing
} else if (ModNum == _TOGGLEUPDATE) {
auto page = getDrawPage();
if (page != nullptr) {
if (page) {
page->KeepUpdated.setValue(!page->KeepUpdated.getValue());
page->recomputeFeature();
}
@@ -337,7 +337,7 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
App::DocumentObject *docObj = *it;
//DrawRichAnno with no parent is child of Page
TechDraw::DrawRichAnno* dra = dynamic_cast<TechDraw::DrawRichAnno*> (*it);
if (dra != nullptr) {
if (dra) {
if (dra->AnnoParent.getValue() == nullptr) {
temp.push_back(*it); //no parent, belongs to page
}
@@ -425,7 +425,7 @@ void ViewProviderPage::setFrameState(bool state)
void ViewProviderPage::toggleFrameState(void)
{
// Base::Console().Message("VPP::toggleFrameState()\n");
if (m_graphicsScene != nullptr) {
if (m_graphicsScene) {
setFrameState(!getFrameState());
m_graphicsScene->refreshViews();
setTemplateMarkers(getFrameState());
@@ -443,7 +443,7 @@ void ViewProviderPage::setTemplateMarkers(bool state)
if (vpt) {
vpt->setMarkers(state);
QGITemplate* t = vpt->getQTemplate();
if (t != nullptr) {
if (t) {
t->updateView(true);
}
}

View File

@@ -149,7 +149,7 @@ bool ViewProviderProjGroupItem::onDelete(const std::vector<std::string> &)
// get the projection
TechDraw::DrawProjGroupItem* proj = getObject();
// check if it is the anchor projection
if ((dpg != nullptr) && (dpg->hasProjection(proj->Type.getValueAsString()))
if (dpg && (dpg->hasProjection(proj->Type.getValueAsString()))
&& (dpg->getAnchor() == dpgi))
isAnchor = true;

View File

@@ -112,7 +112,7 @@ bool ViewProviderRichAnno::doubleClicked(void)
void ViewProviderRichAnno::updateData(const App::Property* p)
{
// only if there is a frame we can enable the frame line parameters
if (getViewObject() != nullptr) {
if (getViewObject()) {
if (getViewObject()->ShowFrame.getValue()) {
LineWidth.setStatus(App::Property::ReadOnly, false);
LineStyle.setStatus(App::Property::ReadOnly, false);

View File

@@ -92,7 +92,7 @@ void ViewProviderTemplate::updateData(const App::Property* prop)
auto t = static_cast<TechDraw::DrawSVGTemplate*>(getTemplate());
if (prop == &(t->Template)) {
MDIViewPage* mdi = getMDIViewPage();
if (mdi != nullptr) {
if (mdi) {
mdi->attachTemplate(t);
mdi->viewAll();
mdi->getViewProviderPage()->setGrid();
@@ -124,7 +124,7 @@ void ViewProviderTemplate::onChanged(const App::Property *prop)
void ViewProviderTemplate::show(void)
{
QGITemplate* qTemplate = getQTemplate();
if (qTemplate != nullptr) {
if (qTemplate) {
qTemplate->show();
}
@@ -134,7 +134,7 @@ void ViewProviderTemplate::show(void)
void ViewProviderTemplate::hide(void)
{
QGITemplate* qTemplate = getQTemplate();
if (qTemplate != nullptr) {
if (qTemplate) {
qTemplate->hide();
}
@@ -151,7 +151,7 @@ QGITemplate* ViewProviderTemplate::getQTemplate(void)
TechDraw::DrawTemplate* dt = getTemplate();
if (dt) {
MDIViewPage* mdi = getMDIViewPage();
if (mdi != nullptr) {
if (mdi) {
return mdi->getQGSPage()->getTemplate();
}
}
@@ -163,7 +163,7 @@ void ViewProviderTemplate::setMarkers(bool state)
// Base::Console().Message("VPT::setMarkers(%d)\n",state);
QGITemplate* qTemplate = getQTemplate();
QGISVGTemplate* qSvgTemplate = dynamic_cast<QGISVGTemplate*> (qTemplate);
if (qSvgTemplate != nullptr) {
if (qSvgTemplate) {
std::vector<TemplateTextField *> textFields = qSvgTemplate->getTextFields();
for (auto& t:textFields) {
if (state) {

View File

@@ -166,9 +166,9 @@ void ViewProviderViewPart::attach(App::DocumentObject *pcFeat)
{
TechDraw::DrawViewMulti* dvm = dynamic_cast<TechDraw::DrawViewMulti*>(pcFeat);
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail*>(pcFeat);
if (dvm != nullptr) {
if (dvm) {
sPixmap = "TechDraw_TreeMulti";
} else if (dvd != nullptr) {
} else if (dvd) {
sPixmap = "actions/TechDraw_DetailView";
}
@@ -244,7 +244,7 @@ bool ViewProviderViewPart::setEdit(int ModNum)
}
TechDraw::DrawViewPart* dvp = getViewObject();
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail*>(dvp);
if (dvd != nullptr) {
if (dvd) {
// clear the selection (convenience)
Gui::Selection().clearSelection();
Gui::Control().showDialog(new TaskDlgDetail(dvd));

View File

@@ -536,7 +536,7 @@ void MRichTextEdit::slotCursorPositionChanged() {
if (m_lastBlockList &&
(l == m_lastBlockList ||
(l != nullptr && m_lastBlockList != nullptr && l->format().style() == m_lastBlockList->format().style()) ) ) {
(l && m_lastBlockList && l->format().style() == m_lastBlockList->format().style()) ) ) {
return;
}
m_lastBlockList = l;