mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Bug fix : in some condition element are not loaded when open a project
If an element are overwrite by a modified element and the terminals of the modified element are moved, the old element is not loaded because some terminal are not found. This commit remove the checking of not found terminal because it's useless now.
This commit is contained in:
parent
07e38236d2
commit
a765fe24be
@ -729,53 +729,40 @@ bool Element::fromXml(QDomElement &e,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, Terminal *> priv_id_adr;
|
QHash<int, Terminal *> priv_id_adr;
|
||||||
int terminals_non_trouvees = 0;
|
|
||||||
|
|
||||||
for (auto *qgi : childItems())
|
for (auto *qgi : childItems())
|
||||||
{
|
{
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi))
|
if (auto terminal_ = qgraphicsitem_cast<Terminal *>(qgi))
|
||||||
{
|
{
|
||||||
bool terminal_trouvee = false;
|
|
||||||
for(auto qde : liste_terminals)
|
for(auto qde : liste_terminals)
|
||||||
{
|
{
|
||||||
if (p -> fromXml(qde))
|
if (terminal_ -> fromXml(qde))
|
||||||
{
|
{
|
||||||
priv_id_adr.insert(qde.attribute(QStringLiteral("id")).toInt(),
|
priv_id_adr.insert(qde.attribute(QStringLiteral("id")).toInt(),
|
||||||
p);
|
terminal_);
|
||||||
terminal_trouvee = true;
|
|
||||||
// We used to break here, because we did not expect
|
|
||||||
// several terminals to share the same position.
|
|
||||||
// Of course, it finally happened.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!terminal_trouvee) ++ terminals_non_trouvees;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminals_non_trouvees > 0)
|
|
||||||
|
//Check that associated id/adress doesn't conflict with table_id_adr
|
||||||
|
for(auto found_id : priv_id_adr.keys())
|
||||||
{
|
{
|
||||||
m_state = QET::GIOK;
|
if (table_id_adr.contains(found_id))
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// verifie que les associations id / adr n'entrent pas en conflit avec table_id_adr
|
|
||||||
foreach(int id_trouve, priv_id_adr.keys())
|
|
||||||
{
|
{
|
||||||
if (table_id_adr.contains(id_trouve))
|
//This element got an id who is already referenced (= conflict)
|
||||||
{
|
m_state = QET::GIOK;
|
||||||
// cet element possede un id qui est deja reference (= conflit)
|
return(false);
|
||||||
m_state = QET::GIOK;
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// copie des associations id / adr
|
|
||||||
foreach(int id_trouve, priv_id_adr.keys()) {
|
|
||||||
table_id_adr.insert(id_trouve,
|
|
||||||
priv_id_adr.value(id_trouve));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Copie the association id/adress
|
||||||
|
for(auto found_id : priv_id_adr.keys()) {
|
||||||
|
table_id_adr.insert(found_id,
|
||||||
|
priv_id_adr.value(found_id));
|
||||||
|
}
|
||||||
|
|
||||||
//load uuid of connected elements
|
//load uuid of connected elements
|
||||||
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
||||||
QStringLiteral("links_uuids"),
|
QStringLiteral("links_uuids"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user