summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jarvie <djarvie@kde.org>2012-03-28 23:07:59 (GMT)
committerDavid Jarvie <djarvie@kde.org>2012-03-28 23:15:18 (GMT)
commit4a3204b75464406ab3b3505e2fe222937aac6750 (patch)
treee2a2e22dee4c73b62d853a1f7f4787ec7eef6d57
parentc53af202e83be668488637001b7e3d5fe15633dc (diff)
Bug 296383: during startup, check that resources calendar opens ok
[KResources build option]: Prevent crash in program initialisation by checking that the resources calendar has opened successfully. BUG:296383
-rw-r--r--kalarm/alarmcalendar.cpp19
-rw-r--r--kalarm/alarmcalendar.h2
-rw-r--r--kalarm/kalarmapp.cpp3
3 files changed, 20 insertions, 4 deletions
diff --git a/kalarm/alarmcalendar.cpp b/kalarm/alarmcalendar.cpp
index dba225b..5f21e67 100644
--- a/kalarm/alarmcalendar.cpp
+++ b/kalarm/alarmcalendar.cpp
@@ -224,11 +224,26 @@ AlarmCalendar::~AlarmCalendar()
}
/******************************************************************************
+* Check whether the calendar is open.
+*/
+bool AlarmCalendar::isOpen()
+{
+#ifndef USE_AKONADI
+ if (mOpen && mCalType == RESOURCES && !AlarmResources::instance())
+ {
+ mCalendar = 0;
+ mOpen = false;
+ }
+#endif
+ return mOpen;
+}
+
+/******************************************************************************
* Open the calendar if not already open, and load it into memory.
*/
bool AlarmCalendar::open()
{
- if (mOpen)
+ if (isOpen())
return true;
if (mCalType == RESOURCES)
{
@@ -287,7 +302,7 @@ bool AlarmCalendar::open()
mCalendar = 0;
#endif
}
- return mOpen;
+ return isOpen();
}
/******************************************************************************
diff --git a/kalarm/alarmcalendar.h b/kalarm/alarmcalendar.h
index 4274fb4..81c5ff9 100644
--- a/kalarm/alarmcalendar.h
+++ b/kalarm/alarmcalendar.h
@@ -120,7 +120,7 @@ class AlarmCalendar : public QObject
bool deleteEvent(const QString& eventID, bool save = false);
#endif
void purgeEvents(const KAEvent::List&);
- bool isOpen() const { return mOpen; }
+ bool isOpen();
QString path() const { return (mCalType == RESOURCES) ? QString() : mUrl.prettyUrl(); }
QString urlString() const { return (mCalType == RESOURCES) ? QString() : mUrl.url(); }
void adjustStartOfDay();
diff --git a/kalarm/kalarmapp.cpp b/kalarm/kalarmapp.cpp
index 2a515b8..2db4c4a 100644
--- a/kalarm/kalarmapp.cpp
+++ b/kalarm/kalarmapp.cpp
@@ -2229,7 +2229,8 @@ bool KAlarmApp::initCheck(bool calendarOnly)
*/
AlarmCalendar::displayCalendar()->open();
- AlarmCalendar::resources()->open();
+ if (!AlarmCalendar::resources()->open())
+ return false;
setArchivePurgeDays();
firstTime = false;