Skip to content

Commit

Permalink
Merge pull request qelectrotech#300 from plc-user/master
Browse files Browse the repository at this point in the history
move code into else-clause to avoid possible crashes
  • Loading branch information
scorpio810 authored Jul 15, 2024
2 parents 6cad599 + 1062d21 commit 30184bd
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions sources/qetgraphicsitem/conductor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,35 +1041,34 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
dom_element.setAttribute("x", QString::number(pos().x()));
dom_element.setAttribute("y", QString::number(pos().y()));

if (terminal1->parentElement()->linkedElements().isEmpty()) {
} else {
dom_element.setAttribute("element1_linked", terminal1->parentElement()->linkedElements().last()->actualLabel());
}

// Terminal is uniquely identified by the uuid of the terminal and the element
if (terminal1->uuid().isNull()) {
// legacy method to identify the terminal
dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compatibility
} else {
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
dom_element.setAttribute("element1_label", terminal1->parentElement()->actualLabel());
if (terminal1->parentElement()->linkedElements().isEmpty()) {
//
} else {
dom_element.setAttribute("element1_linked", terminal1->parentElement()->linkedElements().last()->actualLabel());
}
dom_element.setAttribute("element1_name", terminal1->parentElement()->name());
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
dom_element.setAttribute("terminalname1", terminal1->name());

}

if (terminal2->parentElement()->linkedElements().isEmpty()) {
} else {
dom_element.setAttribute("element2_linked", terminal2->parentElement()->linkedElements().last()->actualLabel());
}

if (terminal2->uuid().isNull()) {
// legacy method to identify the terminal
dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compatibility
} else {
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
dom_element.setAttribute("element2_label", terminal2->parentElement()->actualLabel());
if (terminal2->parentElement()->linkedElements().isEmpty()) {
//
} else {
dom_element.setAttribute("element2_linked", terminal2->parentElement()->linkedElements().last()->actualLabel());
}
dom_element.setAttribute("element2_name", terminal2->parentElement()->name());
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
dom_element.setAttribute("terminalname2", terminal2->name());
Expand Down

0 comments on commit 30184bd

Please sign in to comment.