From ff08ee7ceae8487e03beb288a0244137164b6f58 Mon Sep 17 00:00:00 2001 From: Anakin Date: Thu, 2 Feb 2017 15:10:48 +0100 Subject: [PATCH] error handling when out of file --- QtMeshViewer/Source/MshFile.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/QtMeshViewer/Source/MshFile.cpp b/QtMeshViewer/Source/MshFile.cpp index 7cea3ca..be4ef10 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -87,16 +87,10 @@ void MshFile::loadChunks(QList& destination, qint64 start, const q destination.push_back(tmp_header); // jump to next header - if (!m_file.seek(tmp_header->size + m_file.pos())) - { - OutputDevice::getInstance()->print("WARNING: corrupted file. Trying to continue..", 1); - m_file.unsetError(); - m_file.seek(0); - break; - } + m_file.seek(tmp_header->size + m_file.pos()); // out of file. Maybe a size information is corrupted - if (m_file.error() != QFileDevice::NoError) + if (m_file.atEnd() || m_file.error() != QFileDevice::NoError) { OutputDevice::getInstance()->print("WARNING: corrupted file. Trying to continue..", 1); m_file.unsetError();