Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plotjuggler_app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,18 +1901,25 @@ bool MainWindow::loadLayoutFromFile(QString filename)
return false;
}

// Read file content with explicit UTF-8 encoding to handle Unicode characters
QTextStream stream(&file);
stream.setCodec("UTF-8");
QString fileContent = stream.readAll();
file.close();

QString errorStr;
int errorLine, errorColumn;

QDomDocument domDocument;

if (!domDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn))
if (!domDocument.setContent(fileContent, true, &errorStr, &errorLine, &errorColumn))
{
QMessageBox::information(window(), tr("XML Layout"),
tr("Parse error at line %1:\n%2").arg(errorLine).arg(errorStr));
return false;
}


//-------------------------------------------------
// refresh plugins
QDomElement root = domDocument.namedItem("root").toElement();
Expand Down Expand Up @@ -3054,6 +3061,7 @@ void MainWindow::on_buttonSaveLayout_clicked()
if (file.open(QIODevice::WriteOnly))
{
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream << doc.toString() << "\n";
}
}
Expand Down
Loading