Read symbol files through QFile so paths past 260 characters work on Windows

ElementsLocation::pugiXml() and the qet_directory name lookup opened files
with pugixml's load_file(), which on Windows fails once the full path
reaches MAX_PATH. QFile handles long paths, so exist() and the import
succeeded while uuid(), the name, the informations and the thumbnail of
the same symbol came back empty. Read the bytes with QFile and hand them
to load_buffer().

Reported on #1178 as a false collision from qet.addElement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-02 22:22:18 +13:00
parent 808d6a3c5b
commit af184ed986
2 changed files with 17 additions and 3 deletions
@@ -24,6 +24,7 @@
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QPainter>
#include <QPixmap>
#include <QStyle>
@@ -178,7 +179,12 @@ QString FileElementCollectionItem::localName()
bool readable = false;
QString str(fileSystemPath() % "/qet_directory");
pugi::xml_document docu;
if (docu.load_file(str.toStdWString().c_str()))
// QFile rather than pugi's load_file(), which fails on
// Windows once the full path reaches 260 characters.
QFile file(str);
const QByteArray data = file.open(QIODevice::ReadOnly)
? file.readAll() : QByteArray();
if (!data.isEmpty() && docu.load_buffer(data.constData(), data.size()))
{
if (QString(docu.document_element().name())
== "qet-directory")