Fix bugtracker #240: crash when a recovery file cannot be opened

After a crash, QElectroTech offers to reopen its recovery files. If one
cannot be read, answering OK crashed the program instead of showing the
"could not open" warning: QETProject(KAutoSaveFile *) takes ownership of
the file and deletes it on failure, and openBackupFiles() then read the
file name from the deleted object to build the warning. Read the name
first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
This commit is contained in:
ispyisail
2026-09-25 21:37:17 +12:00
parent 8aefdcc481
commit 07d7aedc26
+3 -1
View File
@@ -2330,6 +2330,8 @@ void QETDiagramEditor::openBackupFiles(QList<KAutoSaveFile *> backup_files)
//Create the project
DialogWaiting::instance(this);
//QETProject takes ownership of file and deletes it, whether or not it opens
const QString file_name = file->managedFile().fileName();
QETProject *project = new QETProject(file, this);
if (project->state() != QETProject::Ok)
{
@@ -2340,7 +2342,7 @@ void QETDiagramEditor::openBackupFiles(QList<KAutoSaveFile *> backup_files)
tr("Échec de l'ouverture du projet", "message box title"),
QString(tr(
"Une erreur est survenue lors de l'ouverture du fichier %1.",
"message box content")).arg(file->managedFile().fileName()));
"message box content")).arg(file_name));
}
delete project;
DialogWaiting::dropInstance();