CLI: disable async crash-recovery backup in headless mode (fixes segfault)

QETProject schedules an asynchronous crash-recovery backup on construction
(writeBackup() -> QtConcurrent::run(QET::writeToFile, ..., &m_backup_file)).
In one-shot CLI mode the QETProject is destroyed as soon as the command
returns, while that background write still references its m_backup_file
member — an intermittent use-after-free segfault during teardown (~1 in 6
runs; observed on --resave and --set-titleblock).

A crash-recovery backup is meaningless for a short-lived headless command,
so add QETProject::setBackupEnabled(false), called from the CLI entry in
main(). writeBackup() then early-returns, so no background write is ever
launched. Fixes the crash for all CLI commands. See #492.
This commit is contained in:
Shane Ringrose
2026-06-12 05:25:44 +12:00
parent 44f0abbb56
commit 19e99aab02
3 changed files with 22 additions and 0 deletions
+9
View File
@@ -43,6 +43,13 @@
static int BACKUP_INTERVAL = 1200000; //interval in ms of backup = 20min
bool QETProject::m_backup_enabled = true;
void QETProject::setBackupEnabled(bool enabled)
{
m_backup_enabled = enabled;
}
/**
@brief QETProject::QETProject
Create a empty project
@@ -1783,6 +1790,8 @@ void QETProject::addDiagram(Diagram *diagram, int pos)
*/
void QETProject::writeBackup()
{
if (!m_backup_enabled)
return;
#ifdef BUILD_WITHOUT_KF5
#else
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove