diff --git a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp index ae4e4a0d16..69384d0000 100644 --- a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp +++ b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp @@ -362,6 +362,9 @@ void CosmeticEdgePy::setCenter(Py::Object arg) pNew = DrawUtil::invertY(pNew); auto oldGeom = getCosmeticEdgePtr()->m_geometry; TechDraw::Circle* oldCircle = dynamic_cast(oldGeom); + if (oldCircle == nullptr) { + throw Py::TypeError("Edge geometry is not a circle"); + } getCosmeticEdgePtr()->permaStart = pNew; getCosmeticEdgePtr()->permaEnd = pNew; diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index 40261289a4..48b10ff94f 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -235,11 +235,11 @@ DrawPage* DrawView::findParentPage() const std::vector parent = getInList(); for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { - page = dynamic_cast(*it); + page = static_cast(*it); } if ((*it)->getTypeId().isDerivedFrom(DrawViewCollection::getClassTypeId())) { - collection = dynamic_cast(*it); + collection = static_cast(*it); page = collection->findParentPage(); } diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index 133d984a80..31792a17bb 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -177,7 +177,7 @@ std::vector ShapeExtractor::getXShapes(const App::Link* xLink) // } Base::Placement childPlm; if (l->getTypeId().isDerivedFrom(App::LinkElement::getClassTypeId())) { - App::LinkElement* cLinkElem = dynamic_cast(l); + App::LinkElement* cLinkElem = static_cast(l); if (cLinkElem->hasPlacement()) { childPlm = cLinkElem->getLinkPlacementProperty()->getValue(); } diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp index 4a5fe5cfb5..23a516f88b 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp @@ -293,6 +293,9 @@ void QGILeaderLine::startPathEdit(void) { saveState(); auto featLeader( dynamic_cast(getViewObject()) ); + if (featLeader == nullptr) { + return; + } double scale = featLeader->getScale(); m_editPath->setScale(scale); diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp index e9754da795..a97154326d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp @@ -463,6 +463,9 @@ void QGIViewBalloon::balloonLabelDragged(bool ctrl) // Base::Console().Message("QGIVB::bLabelDragged(%d)\n", ctrl); m_ctrl = ctrl; auto dvb( dynamic_cast(getViewObject()) ); + if (dvb == nullptr) + return; + if (!m_dragInProgress) { //first drag movement m_dragInProgress = true; if (ctrl) { //moving whole thing, remember Origin offset from Bubble diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 926bf4e7fb..26e7535d53 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -685,7 +685,7 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item) // Base::Console().Message("QGIVP::formatGeomFromCosmetic(%s)\n", cTag.c_str()); bool result = true; auto partFeat( dynamic_cast(getViewObject()) ); - TechDraw::CosmeticEdge* ce = partFeat->getCosmeticEdge(cTag); + TechDraw::CosmeticEdge* ce = partFeat ? partFeat->getCosmeticEdge(cTag) : nullptr; if (ce != nullptr) { item->setNormalColor(ce->m_format.m_color.asValue()); item->setWidth(ce->m_format.m_weight * lineScaleFactor); @@ -701,7 +701,7 @@ bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item) // Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n",sourceIndex); bool result = true; auto partFeat( dynamic_cast(getViewObject()) ); - TechDraw::CenterLine* cl = partFeat->getCenterLine(cTag); + TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr; if (cl != nullptr) { item->setNormalColor(cl->m_format.m_color.asValue()); item->setWidth(cl->m_format.m_weight * lineScaleFactor);