diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2017-10-13 12:43:02 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-11-07 09:49:35 +0000 |
commit | 391fe1d2c15f87e8f3bd31501346436c75b53d38 (patch) | |
tree | 988cc448ec2fc782eab6eb94a69b2de7d4afaaba /src | |
parent | 294eefef0f8cfdba2edd73b5bd2ba7435b102ce5 (diff) |
Deal with trailing spaces and crlf
We ended up having corrupted meshes if the application which exported
the OBJ was adding trailing white spaces. Also make sure we got a test
case using crlf for end of lines.
Change-Id: Iace9dbc3d0d124fefe9e3350d396fdf26555cd17
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/geometryloaders/default/objgeometryloader.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/plugins/geometryloaders/default/objgeometryloader.cpp b/src/plugins/geometryloaders/default/objgeometryloader.cpp index 7184e2f69..6ebe91a09 100644 --- a/src/plugins/geometryloaders/default/objgeometryloader.cpp +++ b/src/plugins/geometryloaders/default/objgeometryloader.cpp @@ -102,6 +102,10 @@ bool ObjGeometryLoader::doLoad(QIODevice *ioDev, const QString &subMesh) if (lineSize > 0 && line[0] != '#') { if (line[lineSize - 1] == '\n') --lineSize; // chop newline + if (line[lineSize - 1] == '\r') + --lineSize; // chop newline also for CRLF format + while (line[lineSize - 1] == ' ' || line[lineSize - 1] == '\t') + --lineSize; // chop trailing spaces const ByteArraySplitter tokens(line, line + lineSize, ' ', QString::SkipEmptyParts); |