diff --git a/Doc/changelog.docu b/Doc/changelog.docu
index a68a7daf..fe44af41 100644
--- a/Doc/changelog.docu
+++ b/Doc/changelog.docu
@@ -18,6 +18,7 @@
- PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)
- PLY Reader: Fixed endless loop on unknown property list type
+- PLY Reader: Fix hang when reading directly from istream (Thanks to Paul Loré for the patch)
- OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.
- OM Writer/Reader: Fixed inconsistent writing/reading of edge properties
- OM Writer/Reader: Add option to store status
diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc
index 37e605a7..33718ff5 100644
--- a/src/OpenMesh/Core/IO/reader/PLYReader.cc
+++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc
@@ -135,6 +135,14 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
return false;
}
+ // Reparse the header
+ if (!can_u_read(_in)) {
+ omerr() << "[PLYReader] : Unable to parse header\n";
+ return false;
+ }
+
+
+
// filter relevant options for reading
bool swap = _opt.check(Options::Swap);
@@ -281,12 +289,6 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl
bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options& _opt) const {
- // Reparse the header
- if (!can_u_read(_in)) {
- omerr() << "[PLYReader] : Unable to parse header\n";
- return false;
- }
-
unsigned int i, j, k, l, idx;
unsigned int nV;
OpenMesh::Vec3f v, n;
@@ -507,12 +509,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap*/, const Options& _opt) const {
- // Reparse the header
- if (!can_u_read(_in)) {
- omerr() << "[PLYReader] : Unable to parse header\n";
- return false;
- }
-
OpenMesh::Vec3f v, n; // Vertex
OpenMesh::Vec2f t; // TexCoords
BaseImporter::VHandles vhandles;