Commit 40df81fe authored by David Jarvie's avatar David Jarvie
Browse files

QFile -> QSaveFile to reliably save autostart file

parent a8645b85
Pipeline #20767 passed with stage
in 5 minutes and 58 seconds
......@@ -9,7 +9,7 @@ KAlarm Change Log
=== Version 2.14.2 (KDE Applications 20.04.2) --- 21 May 2020 ===
+ Make multiple KAlarm invocations work (Qt >5.12, Frameworks >5.60) [KDE Bug 417108]
+ Fix failure to set no-autostart for non-KDE desktops, if a writable autostart directory exists.
+ Fix failure to set no-autostart for non-KDE desktops, if a writable autostart file exists.
=== Version 2.14.1 (KDE Applications 20.04.1) --- 11 May 2020 ===
+ Correctly interpret resource IDs in command line and DBus calls.
......
......@@ -37,6 +37,7 @@
#include <KMessageBox>
#include <QFile>
#include <QSaveFile>
#include <QDir>
#include <QStandardPaths>
......@@ -247,7 +248,7 @@ void Preferences::setNoAutoStart(bool yes)
return;
}
}
QFile file(autostartFileRW);
QSaveFile file(autostartFileRW);
if (!file.open(QIODevice::WriteOnly))
{
qCWarning(KALARM_LOG) << "Preferences::setNoAutoStart: Error writing autostart file:" << autostartFileRW;
......@@ -256,6 +257,11 @@ void Preferences::setNoAutoStart(bool yes)
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream << lines.join(QLatin1Char('\n')) << "\n";
if (!file.commit()) // save the file
{
qCWarning(KALARM_LOG) << "Preferences::setNoAutoStart: Error writing autostart file:" << autostartFileRW;
return;
}
qCDebug(KALARM_LOG) << "Preferences::setNoAutoStart: Written" << autostartFileRW;
}
......
......@@ -803,7 +803,7 @@ void AkonadiResource::itemJobDone(KJob* j)
mPendingItemJobs.erase(it);
}
const QByteArray jobClass = j->metaObject()->className();
qCDebug(KALARM_LOG) << "AkonadiResource::itemJobDone:" << jobClass;
qCDebug(KALARM_LOG) << "AkonadiResource::itemJobDone:" << jobClass << "Item id:" << itemId;
if (j->error())
{
QString errMsg;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment