Page MenuHomePhorge

D2542.1775192153.diff
No OneTemporary

Authored By
Unknown
Size
9 KB
Referenced Files
None
Subscribers
None

D2542.1775192153.diff

diff --git a/calendaring/event.cpp b/calendaring/event.cpp
--- a/calendaring/event.cpp
+++ b/calendaring/event.cpp
@@ -76,17 +76,22 @@
void Event::delegate(const std::vector< Attendee >& delegators, const std::vector< Attendee >& delegatees)
{
- //First build a list of attendee references, and insert any missing attendees
- std::vector<Kolab::Attendee*> delegateesRef;
+ //First insert any missing attendees
foreach(const Attendee &a, delegatees) {
- if (Attendee *attendee = getAttendee(a.contact())) {
- delegateesRef.push_back(attendee);
- } else {
+ if (!getAttendee(a.contact())) {
d->attendees.push_back(a);
- delegateesRef.push_back(&d->attendees.back());
}
}
+ //Build a list of attendee references
+ //These are pointers into d->attendees, so we MUST NOT modify that vector after this point!
+ std::vector<Kolab::Attendee*> delegateesRef;
+ foreach(const Attendee &a, delegatees) {
+ Attendee *attendee = getAttendee(a.contact());
+ Q_ASSERT(attendee);
+ delegateesRef.push_back(attendee);
+ }
+
std::vector<Kolab::Attendee*> delegatorsRef;
foreach(const Attendee& a, delegators) {
if (Attendee *attendee = getAttendee(a.contact())) {
diff --git a/conversion/kcalconversion.cpp b/conversion/kcalconversion.cpp
--- a/conversion/kcalconversion.cpp
+++ b/conversion/kcalconversion.cpp
@@ -329,7 +329,7 @@
if (!a.uri().empty()) {
ptr = KCalCore::Attachment(fromStdString(a.uri()), fromStdString(a.mimetype()));
} else {
- ptr = KCalCore::Attachment(QByteArray::fromRawData(a.data().c_str(), a.data().size()).toBase64(), fromStdString(a.mimetype()));
+ ptr = KCalCore::Attachment(QByteArray(a.data().c_str(), a.data().size()), fromStdString(a.mimetype()));
}
if (!a.label().empty()) {
ptr.setLabel(fromStdString(a.label()));
diff --git a/tests/calendaringtest.cpp b/tests/calendaringtest.cpp
--- a/tests/calendaringtest.cpp
+++ b/tests/calendaringtest.cpp
@@ -110,7 +110,9 @@
Kolab::cDateTime previousDate = event.start();
for (int i = 0; i < 9; i++) {
const Kolab::cDateTime nextDate = event.getNextOccurence(previousDate);
- qDebug() << QTest::toString(nextDate);
+ const char *nextDateString = QTest::toString(nextDate);
+ qDebug() << nextDateString;
+ delete[] nextDateString;
QCOMPARE(nextDate, Kolab::cDateTime("Europe/Zurich", previousDate.year(), previousDate.month(), previousDate.day()+1, previousDate.hour(), previousDate.minute(), previousDate.second()));
const Kolab::cDateTime endDate = event.getOccurenceEndDate(nextDate);
// qDebug() << QTest::toString(endDate);
diff --git a/tests/testhelpers.h b/tests/testhelpers.h
--- a/tests/testhelpers.h
+++ b/tests/testhelpers.h
@@ -44,6 +44,19 @@
Q_DECLARE_METATYPE(KCalCore::Todo);
Q_DECLARE_METATYPE(KCalCore::Journal);
+namespace {
+
+ // Appends a C string to a QByteArray and delete[]s the string argument.
+ // Returns a reference to the QByteArray.
+ QByteArray &append(QByteArray &ba, const char *string)
+ {
+ ba += QByteArray(string);
+ delete[] string;
+ return ba;
+ }
+
+}
+
namespace QTest {
template<>
@@ -123,7 +136,7 @@
{
QByteArray ba = "KCalCore::DateTimeList(";
foreach(const QDateTime &i, l) {
- ba += toString(i);
+ append(ba, toString(i));
}
ba += ")";
return qstrdup(ba.data());
@@ -145,20 +158,20 @@
ba += QByteArray::number(r->recurrenceType()) + "\n";
ba += QByteArray::number(r->frequency()) + "\n";
ba += QByteArray::number(r->duration()) + "\n";
- ba += QByteArray(toString(r->startDt())) + "\n";
- ba += QByteArray(toString(r->endDt())) + "\n";
- ba += QByteArray(toString(r->bySeconds())) + "\n";
- ba += QByteArray(toString(r->byMinutes())) + "\n";
- ba += QByteArray(toString(r->byHours())) + "\n";
- ba += QByteArray(toString(r->byDays())) + "\n";
- ba += QByteArray(toString(r->byMonthDays())) + "\n";
- ba += QByteArray(toString(r->byYearDays())) + "\n";
- ba += QByteArray(toString(r->byMonths())) + "\n";
+ append(ba, toString(r->startDt())) += "\n";
+ append(ba, toString(r->endDt())) += "\n";
+ append(ba, toString(r->bySeconds())) += "\n";
+ append(ba, toString(r->byMinutes())) += "\n";
+ append(ba, toString(r->byHours())) += "\n";
+ append(ba, toString(r->byDays())) += "\n";
+ append(ba, toString(r->byMonthDays())) += "\n";
+ append(ba, toString(r->byYearDays())) += "\n";
+ append(ba, toString(r->byMonths())) += "\n";
ba += ")\n";
- ba += QByteArray(toString(at.exDates())) + "\n";
- ba += QByteArray(toString(at.exDateTimes())) + "\n";
- ba += QByteArray(toString(at.rDates())) + "\n";
- ba += QByteArray(toString(at.rDateTimes())) + "\n";
+ append(ba, toString(at.exDates())) += "\n";
+ append(ba, toString(at.exDateTimes())) += "\n";
+ append(ba, toString(at.rDates())) += "\n";
+ append(ba, toString(at.rDateTimes())) += "\n";
}
return qstrdup(ba.data());
@@ -173,15 +186,15 @@
ba += QByteArray::number(at.frequency()) + "\n";
ba += QByteArray::number(at.interval()) + "\n";
ba += QByteArray::number(at.count()) + "\n";
- ba += QByteArray(toString(at.end())) + "\n";
- ba += QByteArray(toString(at.bysecond())) + "\n";
- ba += QByteArray(toString(at.byminute())) + "\n";
- ba += QByteArray(toString(at.byhour())) + "\n";
- ba += QByteArray(toString(at.byday())) + "\n";
- ba += QByteArray(toString(at.bymonthday())) + "\n";
- ba += QByteArray(toString(at.byyearday())) + "\n";
- ba += QByteArray(toString(at.byweekno())) + "\n";
- ba += QByteArray(toString(at.bymonth())) + "\n";
+ append(ba, toString(at.end())) += "\n";
+ append(ba, toString(at.bysecond())) += "\n";
+ append(ba, toString(at.byminute())) += "\n";
+ append(ba, toString(at.byhour())) += "\n";
+ append(ba, toString(at.byday())) += "\n";
+ append(ba, toString(at.bymonthday())) += "\n";
+ append(ba, toString(at.byyearday())) += "\n";
+ append(ba, toString(at.byweekno())) += "\n";
+ append(ba, toString(at.bymonth())) += "\n";
ba += ")";
return qstrdup(ba.data());
}
@@ -213,7 +226,7 @@
{
QByteArray ba = "vector<Kolab::ContactReference>(";
for (std::size_t i = 0; i < v.size(); i++) {
- ba += QByteArray(toString(v.at(i)))+ "\n";
+ append(ba, toString(v.at(i))) += "\n";
}
ba += ")";
return qstrdup(ba.data());
@@ -229,8 +242,8 @@
ba += QByteArray::number(a.role()) + "\n";
ba += QByteArray::number(a.rsvp()) + "\n";
ba += QByteArray::fromStdString(a.contact().uid())+"\n";
- ba += QByteArray(toString(a.delegatedTo()))+"\n";
- ba += QByteArray(toString(a.delegatedFrom()))+ "\n";
+ append(ba, toString(a.delegatedTo())) += "\n";
+ append(ba, toString(a.delegatedFrom())) += "\n";
ba += QByteArray::number(a.cutype())+ "\n";
ba += ")";
return qstrdup(ba.data());
@@ -241,7 +254,7 @@
{
QByteArray ba = "vector<Kolab::Attendee>(";
for (std::size_t i = 0; i < v.size(); i++) {
- ba += QByteArray(toString(v.at(i)))+ "\n";
+ append(ba, toString(v.at(i))) += "\n";
ba += QByteArray("#######################")+ "\n";
}
ba += ")";
@@ -263,7 +276,7 @@
{
QByteArray ba = "vector<Kolab::CustomProperty>(";
for (std::size_t i = 0; i < v.size(); i++) {
- ba += QByteArray(toString(v.at(i)))+ "\n";
+ append(ba, toString(v.at(i))) += "\n";
}
ba += ")";
return qstrdup(ba.data());
@@ -273,8 +286,8 @@
char *toString(const Kolab::Period &p)
{
QByteArray ba = "Kolab::Period(";
- ba += QByteArray(toString(p.start))+ "\n";
- ba += QByteArray(toString(p.end))+ "\n";
+ append(ba, toString(p.start)) += "\n";
+ append(ba, toString(p.end)) += "\n";
ba += ")";
return qstrdup(ba.data());
}
@@ -284,7 +297,7 @@
{
QByteArray ba = "vector<Kolab::Period>(";
for (std::size_t i = 0; i < v.size(); i++) {
- ba += QByteArray(toString(v.at(i)))+ "\n";
+ append(ba, toString(v.at(i))) += "\n";
}
ba += ")";
return qstrdup(ba.data());
@@ -298,7 +311,7 @@
ba += QByteArray::fromStdString(p.eventUid())+ "\n";
ba += QByteArray::fromStdString(p.eventLocation())+ "\n";
ba += QByteArray::fromStdString(p.eventSummary())+ "\n";
- ba += QByteArray(toString(p.periods()))+ "\n";
+ append(ba, toString(p.periods())) += "\n";
ba += ")";
return qstrdup(ba.data());
}

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 4:55 AM (18 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18794646
Default Alt Text
D2542.1775192153.diff (9 KB)

Event Timeline