mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 23:54:22 +01:00
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:
@@ -2330,6 +2330,8 @@ void QETDiagramEditor::openBackupFiles(QList<KAutoSaveFile *> backup_files)
|
|||||||
//Create the project
|
//Create the project
|
||||||
DialogWaiting::instance(this);
|
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);
|
QETProject *project = new QETProject(file, this);
|
||||||
if (project->state() != QETProject::Ok)
|
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"),
|
tr("Échec de l'ouverture du projet", "message box title"),
|
||||||
QString(tr(
|
QString(tr(
|
||||||
"Une erreur est survenue lors de l'ouverture du fichier %1.",
|
"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;
|
delete project;
|
||||||
DialogWaiting::dropInstance();
|
DialogWaiting::dropInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user