mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 17:34:12 +02:00
Fix placing a symbol a second time in a project with an extra category
XmlElementCollection::importCategory() returned the project collection's first category, taken to be "import". A project can hold other top-level categories before it: examples/lmdg.qet has "k_elem" first. Imported symbols were then filed under k_elem/, while every lookup of an imported symbol is under import/ (QETProject::importElement(), XmlElementCollection::addElement()). The first placement worked; the second could not find the copy, tried to import it again and failed. In the editor the drop silently placed nothing; a script's qet.addElement() returned "". Look the category up by name, falling back to the first one as before when a project has none called "import". Test: tst_importcategory places the same symbol twice in a copy of lmdg.qet through --run. It fails without the fix (the second placement returns "") and passes with it. ctest 45/45. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -157,6 +157,16 @@ QDomElement XmlElementCollection::root() const
|
||||
*/
|
||||
QDomElement XmlElementCollection::importCategory() const
|
||||
{
|
||||
//Found by name: a project may hold other top-level categories,
|
||||
//and before the "import" one (lmdg.qet has "k_elem" first). Every
|
||||
//lookup of an imported element is under "import/", so filing it
|
||||
//anywhere else made the next placement of the same symbol fail.
|
||||
for (QDomElement category = root().firstChildElement("category") ;
|
||||
!category.isNull() ;
|
||||
category = category.nextSiblingElement("category")) {
|
||||
if (category.attribute("name") == QLatin1String("import"))
|
||||
return category;
|
||||
}
|
||||
return root().firstChildElement("category");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user