1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 19:55:53 +01:00

Made the code compile on QT5 < 5.9

+ propper error handling
This commit is contained in:
Martin Tůma 2019-11-15 23:41:30 +01:00
parent 6076c9d82e
commit 3721084d21

View File

@ -402,18 +402,20 @@ static quint32 readImageInfo(QDataStream &stream, Waypoint &waypoint,
ba.resize(size); ba.resize(size);
stream.readRawData(ba.data(), ba.size()); stream.readRawData(ba.data(), ba.size());
QBuffer buf(&ba); if (tempDir().isValid()) {
QImageReader ir(&buf); QBuffer buf(&ba);
QImageReader ir(&buf);
QByteArray id(fileName.toUtf8() + QByteArray::number(imgId++)); QByteArray id(fileName.toUtf8() + QByteArray::number(imgId++));
QFile imgFile(tempDir().filePath(QString("%0.%1").arg( QFile imgFile(tempDir().path() + "/" + QString("%0.%1").arg(
QCryptographicHash::hash(id, QCryptographicHash::Sha1).toHex(), QCryptographicHash::hash(id, QCryptographicHash::Sha1).toHex(),
QString(ir.format())))); QString(ir.format())));
imgFile.open(QIODevice::WriteOnly); imgFile.open(QIODevice::WriteOnly);
imgFile.write(ba); imgFile.write(ba);
imgFile.close(); imgFile.close();
waypoint.addImage(ImageInfo(imgFile.fileName(), ir.size())); waypoint.addImage(ImageInfo(imgFile.fileName(), ir.size()));
}
if (size + 5 != rh.size) if (size + 5 != rh.size)
stream.setStatus(QDataStream::ReadCorruptData); stream.setStatus(QDataStream::ReadCorruptData);