summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookdb.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp
index 2ac9a0c..a26fe8f 100644
--- a/library/datebookdb.cpp
+++ b/library/datebookdb.cpp
@@ -688,97 +688,98 @@ void DateBookDB::loadFile( const QString &strFile )
FRType,
FRWeekdays,
FRPosition,
FRFreq,
FRHasEndDate,
FREndDate,
FRStart,
FREnd,
FNote,
FCreated,
FAction,
FActionKey,
FJournalOrigHadRepeat
};
QAsciiDict<int> dict( 97 );
dict.setAutoDelete( TRUE );
dict.insert( "description", new int(FDescription) );
dict.insert( "location", new int(FLocation) );
dict.insert( "categories", new int(FCategories) );
dict.insert( "uid", new int(FUid) );
dict.insert( "type", new int(FType) );
dict.insert( "alarm", new int(FAlarm) );
dict.insert( "sound", new int(FSound) );
dict.insert( "rtype", new int(FRType) );
dict.insert( "rweekdays", new int(FRWeekdays) );
dict.insert( "rposition", new int(FRPosition) );
dict.insert( "rfreq", new int(FRFreq) );
dict.insert( "rhasenddate", new int(FRHasEndDate) );
dict.insert( "enddt", new int(FREndDate) );
dict.insert( "start", new int(FRStart) );
dict.insert( "end", new int(FREnd) );
dict.insert( "note", new int(FNote) );
dict.insert( "created", new int(FCreated) );
dict.insert( "action", new int(FAction) );
dict.insert( "actionkey", new int(FActionKey) );
dict.insert( "actionorig", new int (FJournalOrigHadRepeat) );
QByteArray ba = f.readAll();
char* dt = ba.data();
int len = ba.size();
int currentAction,
journalKey,
origHadRepeat; // should be bool, but we need tri-state(not being used)
int i = 0;
char *point;
- while ( ( point = strstr( dt+i, "<event " ) ) != 0 ) {
+ // hack to get rid of segfaults after reading </DATEBOOK>
+ while ( (dt+i != 0) && (( point = strstr( dt+i, "<event " ) ) != 0 )) {
i = point - dt;
// if we are reading in events in the general case,
// we are just adding them, so let the actions represent that...
currentAction = ACTION_ADD;
journalKey = -1;
origHadRepeat = -1;
// some temporary variables for dates and times ...
//int startY = 0, startM = 0, startD = 0, starth = 0, startm = 0, starts = 0;
//int endY = 0, endM = 0, endD = 0, endh = 0, endm = 0, ends = 0;
//int enddtY = 0, enddtM = 0, enddtD = 0;
// ... for the alarm settings ...
int alarmTime = -1; Event::SoundTypeChoice alarmSound = Event::Silent;
// ... and for the recurrence
Event::RepeatPattern rp;
Event e;
i += 7;
while( 1 ) {
while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
++i;
if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
break;
// we have another attribute, read it.
int j = i;
while ( j < len && dt[j] != '=' )
++j;
char *attr = dt+i;
dt[j] = '\0';
i = ++j; // skip =
while ( i < len && dt[i] != '"' )
++i;
j = ++i;
bool haveAmp = FALSE;
bool haveUtf = FALSE;
while ( j < len && dt[j] != '"' ) {
if ( dt[j] == '&' )
haveAmp = TRUE;
if ( ((unsigned char)dt[j]) > 0x7f )
haveUtf = TRUE;
++j;
}
if ( i == j ) {
// leave out empty attributes
i = j + 1;
continue;