diff --git a/src/FileSystem/FileSystem.cpp b/src/FileSystem/FileSystem.cpp index 208bfaa..07d476c 100644 --- a/src/FileSystem/FileSystem.cpp +++ b/src/FileSystem/FileSystem.cpp @@ -100,12 +100,29 @@ QList FileSystem::readContactsOldFormat(QString file) in >> version; qDebug() << "Read " << version << " Hush contacts from disk..."; qDebug() << "Detected old addressbook format"; - QList> stuff; - in >> stuff; - for (int i=0; i < stuff.size(); i++) + if(in.status() == QDataStream::ReadCorruptData) { - ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]); - contacts.push_back(contact); + qDebug() << "Error reading contacts! ---> Your hush contacts from disk maybe corrupted"; + QFile::rename(file, file + QString(".corrupted")); + QMessageBox::critical( + nullptr, + QObject::tr("Error reading contacts!"), + QObject::tr("Your hush contacts from disk maybe corrupted"), + QMessageBox::Ok + ); + } + else + { + qDebug() << "Read " << version << " Hush contacts from disk..."; + QList> stuff; + in >> stuff; + for (int i=0; i < stuff.size(); i++) + { + ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]); + contacts.push_back(contact); + } + + qDebug() << "Hush contacts readed from disk..."; } _file.close();