Prefer to use BaseClass's isDerivedFrom<T> over non template or Base::Type's

Regex based changes, manually verified
This commit is contained in:
Benjamin Nauck
2025-01-16 21:27:50 +01:00
parent 6a3eb2ab49
commit 6f535f19fb
166 changed files with 484 additions and 497 deletions

View File

@@ -100,7 +100,7 @@ std::vector<std::string> CommandHelpers::getSelectedSubElements(Gui::Command* cm
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
if ((*itSel).getObject()->isDerivedFrom<TechDraw::DrawViewPart>()) {
dvp = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
subNames = (*itSel).getSubNames();
break;
@@ -144,12 +144,12 @@ void CommandHelpers::getSelectedShapes(Gui::Command* cmd,
for (auto& sel : selection) {
bool is_linked = false;
auto obj = sel.getObject();
if (obj->isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) {
if (obj->isDerivedFrom<TechDraw::DrawPage>()) {
continue;
}
if (obj->isDerivedFrom(App::LinkElement::getClassTypeId())
|| obj->isDerivedFrom(App::LinkGroup::getClassTypeId())
|| obj->isDerivedFrom(App::Link::getClassTypeId())) {
if (obj->isDerivedFrom<App::LinkElement>()
|| obj->isDerivedFrom<App::LinkGroup>()
|| obj->isDerivedFrom<App::Link>()) {
is_linked = true;
}
// If parent of the obj is a link to another document, we possibly need to treat non-link obj as linked, too
@@ -162,9 +162,9 @@ void CommandHelpers::getSelectedShapes(Gui::Command* cmd,
continue;
}
// 2nd, do we really have a link to obj?
if (parent->isDerivedFrom(App::LinkElement::getClassTypeId())
|| parent->isDerivedFrom(App::LinkGroup::getClassTypeId())
|| parent->isDerivedFrom(App::Link::getClassTypeId())) {
if (parent->isDerivedFrom<App::LinkElement>()
|| parent->isDerivedFrom<App::LinkGroup>()
|| parent->isDerivedFrom<App::Link>()) {
// We have a link chain from this document to obj, and obj is in another document -> it is an XLink target
is_linked = true;
}