From 23ac56db3aa77b298f20b288aadf503fd09a23a9 Mon Sep 17 00:00:00 2001 From: zecke Date: Wed, 19 Jun 2002 17:38:11 +0000 Subject: 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. --- (limited to 'core/pim') 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 @@ -562,6 +562,8 @@ void AbTable::loadFile( const QString &strFile, bool journalFile ) 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; @@ -797,17 +799,24 @@ 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(item(row, 0)); - contactList.remove( ati ); - ati->setItem( strName, strContact ); - contactList.insert( ati, cnt ); - - ati = static_cast(item(row, 1)); - ati->setItem( strContact, strName ); + if ( ati != 0 ) { + contactList.remove( ati ); + ati->setItem( strName, strContact ); + contactList.insert( ati, cnt ); + + ati = static_cast(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 ) @@ -1083,7 +1092,7 @@ void AbTable::updateVisible() if ( showChar == '#' ) { if (tmpStr == "a") hide = true; - + if (tmpStr == "b") hide = true; -- cgit v0.9.0.2