summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-19 17:38:11 (UTC)
committer zecke <zecke>2002-06-19 17:38:11 (UTC)
commit23ac56db3aa77b298f20b288aadf503fd09a23a9 (patch) (side-by-side diff)
treefe820ec743bbf829d31ae3ab1436a41a69b1855c
parentdee5f6c5a3bd982913d0b234fb9392ce68d5df63 (diff)
downloadopie-23ac56db3aa77b298f20b288aadf503fd09a23a9.zip
opie-23ac56db3aa77b298f20b288aadf503fd09a23a9.tar.gz
opie-23ac56db3aa77b298f20b288aadf503fd09a23a9.tar.bz2
Tille ask Diana how she was able to trigger that bug?
I nominate her for the bug finding queen 2002. Ok I just fixed two possible crashes with the risk of losing data.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index e9e6a0b..3fa1a7c 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -549,32 +549,34 @@ void AbTable::load( const QString &fn )
}
setSorting( true );
resort();
}
void AbTable::loadFile( const QString &strFile, bool journalFile )
{
// QTime t;
// t.start();
QFile f( strFile );
if ( !f.open(IO_ReadOnly) )
return;
QList<Contact> list;
list.setAutoDelete( TRUE );
QByteArray ba = f.readAll();
f.close();
+ if (ba.isEmpty() )
+ return;
char *uc = ba.data();//(QChar *)data.unicode();
int len = ba.size();//data.length();
bool foundAction = false;
Contact::journal_action action;
bool foundKey = false;
int journalKey = 0;
const int JOURNALACTION = Qtopia::Notes + 1;
const int JOURNALROW = JOURNALACTION + 1;
// **********************************
// CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!!
// **********************************
QAsciiDict<int> dict( 47 );
dict.setAutoDelete( TRUE );
dict.insert( "Uid", new int(Qtopia::AddressUid) );
@@ -784,43 +786,50 @@ void AbTable::internalAddEntries( QList<Contact> &list )
{
setUpdatesEnabled( FALSE );
setNumRows( list.count() );
int row = 0;
Contact *it;
for ( it = list.first(); it; it = list.next() )
insertIntoTable( *it, row++ );
resort();
setUpdatesEnabled( TRUE );
}
void AbTable::journalFreeReplace( const Contact &cnt, int row )
{
QString strName,
strContact;
- AbTableItem *ati;
+ AbTableItem *ati = 0l;
strName = findContactName( cnt );
strContact = findContactContact( cnt );
ati = static_cast<AbTableItem*>(item(row, 0));
- contactList.remove( ati );
- ati->setItem( strName, strContact );
- contactList.insert( ati, cnt );
-
- ati = static_cast<AbTableItem*>(item(row, 1));
- ati->setItem( strContact, strName );
+ if ( ati != 0 ) {
+ contactList.remove( ati );
+ ati->setItem( strName, strContact );
+ contactList.insert( ati, cnt );
+
+ ati = static_cast<AbTableItem*>(item(row, 1));
+ ati->setItem( strContact, strName );
+ }else{
+ int myrows = numRows();
+ setNumRows( myrows + 1 );
+ insertIntoTable( cnt, myrows );
+ // gets deleted when returning
+ }
}
void AbTable::journalFreeRemove( int row )
{
AbTableItem *ati;
ati = static_cast<AbTableItem*>(item(row, 0));
if ( !ati )
return;
contactList.remove( ati );
realignTable( row );
}
#if QT_VERSION <= 230
#ifndef SINGLE_APP
void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
{
@@ -1070,33 +1079,33 @@ void AbTable::updateVisible()
hide = false;
break;
}
}
}
}
}
if ( showChar != '\0' ) {
tmpStr = fileAsName.left(1);
tmpStr = tmpStr.lower();
if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) {
hide = true;
}
if ( showChar == '#' ) {
if (tmpStr == "a")
hide = true;
-
+
if (tmpStr == "b")
hide = true;
if (tmpStr == "c")
hide = true;
if (tmpStr == "d")
hide = true;
if (tmpStr == "e")
hide = true;
if (tmpStr == "f")
hide = true;
if (tmpStr == "g")