summaryrefslogtreecommitdiff
authortille <tille>2002-05-15 09:53:39 (UTC)
committer tille <tille>2002-05-15 09:53:39 (UTC)
commit7977d9c5793100040b645974be1573572a550f62 (patch) (unidiff)
treebd1265a21c2ea7495fa0e9446e80239e25c5aeed
parentb1198cf567577dba9710b9fb19d924c766202c38 (diff)
downloadopie-7977d9c5793100040b645974be1573572a550f62.zip
opie-7977d9c5793100040b645974be1573572a550f62.tar.gz
opie-7977d9c5793100040b645974be1573572a550f62.tar.bz2
hack to get rig of segfaults after reading </DATEBOOK>
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
@@ -704,65 +704,66 @@ void DateBookDB::loadFile( const QString &strFile )
704 dict.setAutoDelete( TRUE ); 704 dict.setAutoDelete( TRUE );
705 dict.insert( "description", new int(FDescription) ); 705 dict.insert( "description", new int(FDescription) );
706 dict.insert( "location", new int(FLocation) ); 706 dict.insert( "location", new int(FLocation) );
707 dict.insert( "categories", new int(FCategories) ); 707 dict.insert( "categories", new int(FCategories) );
708 dict.insert( "uid", new int(FUid) ); 708 dict.insert( "uid", new int(FUid) );
709 dict.insert( "type", new int(FType) ); 709 dict.insert( "type", new int(FType) );
710 dict.insert( "alarm", new int(FAlarm) ); 710 dict.insert( "alarm", new int(FAlarm) );
711 dict.insert( "sound", new int(FSound) ); 711 dict.insert( "sound", new int(FSound) );
712 dict.insert( "rtype", new int(FRType) ); 712 dict.insert( "rtype", new int(FRType) );
713 dict.insert( "rweekdays", new int(FRWeekdays) ); 713 dict.insert( "rweekdays", new int(FRWeekdays) );
714 dict.insert( "rposition", new int(FRPosition) ); 714 dict.insert( "rposition", new int(FRPosition) );
715 dict.insert( "rfreq", new int(FRFreq) ); 715 dict.insert( "rfreq", new int(FRFreq) );
716 dict.insert( "rhasenddate", new int(FRHasEndDate) ); 716 dict.insert( "rhasenddate", new int(FRHasEndDate) );
717 dict.insert( "enddt", new int(FREndDate) ); 717 dict.insert( "enddt", new int(FREndDate) );
718 dict.insert( "start", new int(FRStart) ); 718 dict.insert( "start", new int(FRStart) );
719 dict.insert( "end", new int(FREnd) ); 719 dict.insert( "end", new int(FREnd) );
720 dict.insert( "note", new int(FNote) ); 720 dict.insert( "note", new int(FNote) );
721 dict.insert( "created", new int(FCreated) ); 721 dict.insert( "created", new int(FCreated) );
722 dict.insert( "action", new int(FAction) ); 722 dict.insert( "action", new int(FAction) );
723 dict.insert( "actionkey", new int(FActionKey) ); 723 dict.insert( "actionkey", new int(FActionKey) );
724 dict.insert( "actionorig", new int (FJournalOrigHadRepeat) ); 724 dict.insert( "actionorig", new int (FJournalOrigHadRepeat) );
725 725
726 726
727 QByteArray ba = f.readAll(); 727 QByteArray ba = f.readAll();
728 char* dt = ba.data(); 728 char* dt = ba.data();
729 int len = ba.size(); 729 int len = ba.size();
730 int currentAction, 730 int currentAction,
731 journalKey, 731 journalKey,
732 origHadRepeat; // should be bool, but we need tri-state(not being used) 732 origHadRepeat; // should be bool, but we need tri-state(not being used)
733 733
734 int i = 0; 734 int i = 0;
735 char *point; 735 char *point;
736 while ( ( point = strstr( dt+i, "<event " ) ) != 0 ) { 736 // hack to get rid of segfaults after reading </DATEBOOK>
737 while ( (dt+i != 0) && (( point = strstr( dt+i, "<event " ) ) != 0 )) {
737 i = point - dt; 738 i = point - dt;
738 // if we are reading in events in the general case, 739 // if we are reading in events in the general case,
739 // we are just adding them, so let the actions represent that... 740 // we are just adding them, so let the actions represent that...
740 currentAction = ACTION_ADD; 741 currentAction = ACTION_ADD;
741 journalKey = -1; 742 journalKey = -1;
742 origHadRepeat = -1; 743 origHadRepeat = -1;
743 // some temporary variables for dates and times ... 744 // some temporary variables for dates and times ...
744 //int startY = 0, startM = 0, startD = 0, starth = 0, startm = 0, starts = 0; 745 //int startY = 0, startM = 0, startD = 0, starth = 0, startm = 0, starts = 0;
745 //int endY = 0, endM = 0, endD = 0, endh = 0, endm = 0, ends = 0; 746 //int endY = 0, endM = 0, endD = 0, endh = 0, endm = 0, ends = 0;
746 //int enddtY = 0, enddtM = 0, enddtD = 0; 747 //int enddtY = 0, enddtM = 0, enddtD = 0;
747 748
748 // ... for the alarm settings ... 749 // ... for the alarm settings ...
749 int alarmTime = -1; Event::SoundTypeChoice alarmSound = Event::Silent; 750 int alarmTime = -1; Event::SoundTypeChoice alarmSound = Event::Silent;
750 // ... and for the recurrence 751 // ... and for the recurrence
751 Event::RepeatPattern rp; 752 Event::RepeatPattern rp;
752 Event e; 753 Event e;
753 754
754 i += 7; 755 i += 7;
755 756
756 while( 1 ) { 757 while( 1 ) {
757 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 758 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
758 ++i; 759 ++i;
759 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 760 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
760 break; 761 break;
761 // we have another attribute, read it. 762 // we have another attribute, read it.
762 int j = i; 763 int j = i;
763 while ( j < len && dt[j] != '=' ) 764 while ( j < len && dt[j] != '=' )
764 ++j; 765 ++j;
765 char *attr = dt+i; 766 char *attr = dt+i;
766 dt[j] = '\0'; 767 dt[j] = '\0';
767 i = ++j; // skip = 768 i = ++j; // skip =
768 while ( i < len && dt[i] != '"' ) 769 while ( i < len && dt[i] != '"' )