From 07d7aedc265d6d682a8ea2c0e95c384d11b3d1f3 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 25 Sep 2026 21:37:17 +1200 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG --- sources/qetdiagrameditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 6db163f87..7ae88cda6 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -2330,6 +2330,8 @@ void QETDiagramEditor::openBackupFiles(QList 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 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();