mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-30 05:44:14 +02:00
Fix #391: use wide-char path for pugixml on Windows to handle Unicode paths
pugi::xml_document::load_file(const char*) calls fopen/fopen_s on Windows, which uses the ANSI codepage — not UTF-8. This silently fails when the collection path contains accented characters (é, ü, ñ, …) or is longer than the narrow-API MAX_PATH limit, leaving the collection panel with no element names or illustrations. Switch both call sites to toStdWString().c_str() which invokes the load_file(const wchar_t*) overload. On Windows pugixml calls _wfopen, the wide Unicode API that handles all valid Unicode paths. On Linux/macOS the same overload converts wchar_t to UTF-8 internally and calls fopen, so behaviour is unchanged on those platforms. Affected files: sources/ElementsCollection/fileelementcollectionitem.cpp (qet_directory load) sources/ElementsCollection/elementslocation.cpp (element .elmt load, both branches) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -701,11 +701,11 @@ pugi::xml_document ElementsLocation::pugiXml() const
|
||||
if (!m_project)
|
||||
{
|
||||
#ifndef Q_OS_LINUX
|
||||
if (docu.load_file(m_file_system_path.toStdString().c_str())) {
|
||||
if (docu.load_file(m_file_system_path.toStdWString().c_str())) {
|
||||
docu.save(m_string_stream);
|
||||
}
|
||||
#else
|
||||
docu.load_file(m_file_system_path.toStdString().c_str());
|
||||
docu.load_file(m_file_system_path.toStdWString().c_str());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
||||
@@ -138,7 +138,7 @@ QString FileElementCollectionItem::localName()
|
||||
{
|
||||
QString str(fileSystemPath() % "/qet_directory");
|
||||
pugi::xml_document docu;
|
||||
if(docu.load_file(str.toStdString().c_str()))
|
||||
if(docu.load_file(str.toStdWString().c_str()))
|
||||
{
|
||||
if (QString(docu.document_element().name())
|
||||
== "qet-directory")
|
||||
|
||||
Reference in New Issue
Block a user