mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-02 18:14:13 +02:00
Merge pull request #564 from DieterMayerOSS/pr/restore-qt6-autosave
Restore crash-recovery autosave on Qt6
This commit is contained in:
+6
-10
@@ -1914,21 +1914,17 @@ void QETProject::writeBackup()
|
|||||||
{
|
{
|
||||||
if (!m_backup_enabled)
|
if (!m_backup_enabled)
|
||||||
return;
|
return;
|
||||||
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
//Don't launch a new backup while the previous one is still writing:
|
//Don't launch a new backup while the previous one is still writing:
|
||||||
//both would write through &m_backup_file on different threads.
|
//both would write through &m_backup_file on different threads.
|
||||||
if (m_backup_future.isRunning())
|
if (m_backup_future.isRunning())
|
||||||
return;
|
return;
|
||||||
|
//Capture the document by value (implicitly shared, so cheap): the
|
||||||
|
//Qt5-style QtConcurrent::run(function, reference-args) call did not
|
||||||
|
//survive the Qt6 API change, a lambda behaves identically on both.
|
||||||
QDomDocument xml_project(toXml());
|
QDomDocument xml_project(toXml());
|
||||||
m_backup_future = QtConcurrent::run(
|
m_backup_future = QtConcurrent::run([this, xml_project]() mutable {
|
||||||
QET::writeToFile,xml_project,&m_backup_file,nullptr);
|
return QET::writeToFile(xml_project, &m_backup_file, nullptr);
|
||||||
# else
|
});
|
||||||
# if TODO_LIST
|
|
||||||
# pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
qDebug() << "Help code for QT 6 or later"
|
|
||||||
<< "QtConcurrent::run its backwards now...function, object, args";
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user