Commit 414e553a authored by David Jarvie's avatar David Jarvie

Bug 375615: Don't show misleading error message if command alarm fails

If it's the last or only occurrence of a command alarm and its
execution fails, don't attempt to update the event's error status,
to avoid outputting misleading "Failed to update alarm" message.
parent 757e3cba
......@@ -4,9 +4,10 @@ KAlarm Change Log
+ Report if terminal for command alarms is not configured.
+ Don't allow 'auto-hide in system tray' on Unity desktop [KDE Bug 373848]
=== Version 2.11.13 (KDE Applications 16.12.2) --- 26 January 2017 ===
=== Version 2.11.13 (KDE Applications 16.12.2) --- 29 January 2017 ===
+ Fix system tray icon used for "some alarms disabled"
+ Improved system tray icons (requires Plasma 5.9) [KDE Bug 362631]
+ Don't show misleading "Failed to update alarm" if command alarm fails [KDE Bug 375615]
=== Version 2.11.12 (KDE Applications 16.12.1) --- 1 January 2017 ===
+ Fix Export Alarms file save error [KDE Bug 374337]
......
......@@ -75,9 +75,6 @@
static const int AKONADI_TIMEOUT = 30; // timeout (seconds) for Akonadi collections to be populated
static void setEventCommandError(const KAEvent&, KAEvent::CmdErrType);
static void clearEventCommandError(const KAEvent&, KAEvent::CmdErrType);
/******************************************************************************
* Find the maximum number of seconds late which a late-cancel alarm is allowed
* to be. This is calculated as the late cancel interval, plus a few seconds
......@@ -1770,6 +1767,12 @@ bool KAlarmApp::cancelAlarm(KAEvent& event, KAAlarm::Type alarmType, bool update
event.removeExpiredAlarm(alarmType);
if (!event.alarmCount())
{
// If it's a command alarm being executed, mark it as deleted
ProcData* pd = findCommandProcess(event.id());
if (pd)
pd->eventDeleted = true;
// Delete it
KAlarm::deleteEvent(event, false);
return true;
}
......@@ -2376,9 +2379,15 @@ void KAlarmApp::stopAudio()
MessageWin::stopAudio();
}
void setEventCommandError(const KAEvent& event, KAEvent::CmdErrType err)
/******************************************************************************
* Set the command error for the specified alarm.
*/
void KAlarmApp::setEventCommandError(const KAEvent& event, KAEvent::CmdErrType err) const
{
ProcData* pd = findCommandProcess(event.id());
if (pd && pd->eventDeleted)
return; // the alarm has been deleted, so can't set error status
if (err == KAEvent::CMD_ERROR_POST && event.commandError() == KAEvent::CMD_ERROR_PRE)
err = KAEvent::CMD_ERROR_PRE_POST;
event.setCommandError(err);
......@@ -2388,8 +2397,15 @@ void setEventCommandError(const KAEvent& event, KAEvent::CmdErrType err)
AkonadiModel::instance()->updateCommandError(event);
}
void clearEventCommandError(const KAEvent& event, KAEvent::CmdErrType err)
/******************************************************************************
* Clear the command error for the specified alarm.
*/
void KAlarmApp::clearEventCommandError(const KAEvent& event, KAEvent::CmdErrType err) const
{
ProcData* pd = findCommandProcess(event.id());
if (pd && pd->eventDeleted)
return; // the alarm has been deleted, so can't set error status
KAEvent::CmdErrType newerr = static_cast<KAEvent::CmdErrType>(event.commandError() & ~err);
event.setCommandError(newerr);
KAEvent* ev = AlarmCalendar::resources()->event(EventId(event));
......@@ -2401,13 +2417,28 @@ void clearEventCommandError(const KAEvent& event, KAEvent::CmdErrType err)
AkonadiModel::instance()->updateCommandError(event);
}
/******************************************************************************
* Find the currently executing command process for an event ID, if any.
*/
KAlarmApp::ProcData* KAlarmApp::findCommandProcess(const QString& eventId) const
{
for (int i = 0, end = mCommandProcesses.count(); i < end; ++i)
{
ProcData* pd = mCommandProcesses[i];
if (pd->event->id() == eventId)
return pd;
}
return nullptr;
}
KAlarmApp::ProcData::ProcData(ShellProcess* p, KAEvent* e, KAAlarm* a, int f)
: process(p),
event(e),
alarm(a),
messageBoxParent(nullptr),
flags(f)
flags(f),
eventDeleted(false)
{ }
KAlarmApp::ProcData::~ProcData()
......
......@@ -154,6 +154,7 @@ class KAlarmApp : public QApplication
QPointer<QWidget> messageBoxParent;
QStringList tempFiles;
int flags;
bool eventDeleted;
};
struct ActionQEntry
{
......@@ -186,6 +187,9 @@ class KAlarmApp : public QApplication
void commandErrorMsg(const ShellProcess*, const KAEvent&, const KAAlarm*, int flags = 0, const QStringList& errmsgs = QStringList());
void purge(int daysToKeep);
QStringList scheduledAlarmList();
void setEventCommandError(const KAEvent&, KAEvent::CmdErrType) const;
void clearEventCommandError(const KAEvent&, KAEvent::CmdErrType) const;
ProcData* findCommandProcess(const QString& eventId) const;
static KAlarmApp* mInstance; // the one and only KAlarmApp instance
static int mActiveCount; // number of active instances without main windows
......
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