From b2b2f6aabfa2ca125035f681adcbee3adf2e41cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Tue, 12 Jul 2022 17:09:29 +0200 Subject: [PATCH] [TechDraw] Improve readability of TaskDetail.cpp --- src/Mod/TechDraw/Gui/TaskDetail.cpp | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index e6b6a23cb4..483b3a6297 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -575,43 +575,39 @@ QPointF TaskDetail::getAnchorScene() DrawViewPart* TaskDetail::getBaseFeat() { // Base::Console().Message("TD::getBaseFeat()\n"); - DrawViewPart* result = nullptr; if (m_doc != nullptr) { App::DocumentObject* baseObj = m_doc->getObject(m_baseName.c_str()); if (baseObj != nullptr) { - result = static_cast(baseObj); + return static_cast(baseObj); } } - if (result == nullptr) { - std::string msg = "TaskDetail - base feature " + - m_baseName + - " not found \n"; - throw Base::TypeError(msg); - } - return result; + + std::string msg = "TaskDetail - base feature " + + m_baseName + + " not found \n"; + throw Base::TypeError(msg); + return nullptr; } // protects against stale pointers DrawViewDetail* TaskDetail::getDetailFeat() { // Base::Console().Message("TD::getDetailFeat()\n"); - DrawViewDetail* result = nullptr; if (m_doc != nullptr) { App::DocumentObject* detailObj = m_doc->getObject(m_detailName.c_str()); if (detailObj != nullptr) { - result = static_cast(detailObj); + return static_cast(detailObj); } } - if (result == nullptr) { - std::string msg = "TaskDetail - detail feature " + - m_detailName + - " not found \n"; + + std::string msg = "TaskDetail - detail feature " + + m_detailName + + " not found \n"; // throw Base::TypeError("TaskDetail - detail feature not found\n"); - throw Base::TypeError(msg); - } - return result; + throw Base::TypeError(msg); + return nullptr; } //******************************************************************************