Addressing some feedback. Making the .obj.gz checks more specific and adding an exception if gunzip fails.

This commit is contained in:
1P-Cusack 2017-06-22 11:21:19 -04:00
parent 781e2f409f
commit f8c30c70e8

View file

@ -175,7 +175,7 @@ void GeometryReader::run() {
if (!urlname.isEmpty() && !_url.path().isEmpty() && if (!urlname.isEmpty() && !_url.path().isEmpty() &&
(_url.path().toLower().endsWith(".fbx") || (_url.path().toLower().endsWith(".fbx") ||
_url.path().toLower().endsWith(".obj") || _url.path().toLower().endsWith(".obj") ||
_url.path().toLower().endsWith(".gz"))) { _url.path().toLower().endsWith(".obj.gz"))) {
FBXGeometry::Pointer fbxGeometry; FBXGeometry::Pointer fbxGeometry;
if (_url.path().toLower().endsWith(".fbx")) { if (_url.path().toLower().endsWith(".fbx")) {
@ -185,11 +185,14 @@ void GeometryReader::run() {
} }
} else if (_url.path().toLower().endsWith(".obj")) { } else if (_url.path().toLower().endsWith(".obj")) {
fbxGeometry.reset(OBJReader().readOBJ(_data, _mapping, _combineParts, _url)); fbxGeometry.reset(OBJReader().readOBJ(_data, _mapping, _combineParts, _url));
} else if (_url.path().toLower().endsWith(".gz")) { } else if (_url.path().toLower().endsWith(".obj.gz")) {
QByteArray uncompressedData; QByteArray uncompressedData;
if (gunzip(_data, uncompressedData)){ if (gunzip(_data, uncompressedData)){
fbxGeometry.reset(OBJReader().readOBJ(uncompressedData, _mapping, _combineParts, _url)); fbxGeometry.reset(OBJReader().readOBJ(uncompressedData, _mapping, _combineParts, _url));
} else {
throw QString("failed to decompress .obj.gz" );
} }
} else { } else {
throw QString("unsupported format"); throw QString("unsupported format");
} }