Code cleanup

This commit is contained in:
Martin Tůma 2020-04-15 10:06:57 +02:00
parent a298cfc47d
commit 032c699e8b
3 changed files with 9 additions and 8 deletions

View File

@ -1,11 +1,10 @@
#include <QtEndian> #include <QIODevice>
#include <QDebug>
#include <zlib.h> #include <zlib.h>
#include "gzip.h" #include "gzip.h"
#define CHUNK 16384 #define CHUNK 16384
QByteArray Gzip::uncompress(QIODevice *device, qint64 limit) QByteArray Gzip::uncompress(QIODevice *device, int limit)
{ {
int ret; int ret;
z_stream strm; z_stream strm;

View File

@ -7,7 +7,7 @@ class QIODevice;
namespace Gzip namespace Gzip
{ {
QByteArray uncompress(QIODevice *device, qint64 limit = 0); QByteArray uncompress(QIODevice *device, int limit = 0);
} }
#endif // GZIP_H #endif // GZIP_H

View File

@ -65,12 +65,14 @@ bool PBFHandler::read(QImage *image)
return false; return false;
QByteArray ba; QByteArray ba;
if (isGZIPPBF(magic)) if (isGZIPPBF(magic)) {
ba = Gzip::uncompress(device()); ba = Gzip::uncompress(device());
else if (isPlainPBF(magic)) if (ba.isNull()) {
qCritical() << "Invalid gzip data";
return false;
}
} else if (isPlainPBF(magic))
ba = device()->readAll(); ba = device()->readAll();
if (ba.isNull())
return false;
vector_tile::Tile data; vector_tile::Tile data;
if (!data.ParseFromArray(ba.constData(), ba.size())) { if (!data.ParseFromArray(ba.constData(), ba.size())) {
qCritical() << "Invalid PBF data"; qCritical() << "Invalid PBF data";