Browse Source

Fixed reading gltf validator json report.

Vicente Penades 5 years ago
parent
commit
6b21ee1c4c
1 changed files with 4 additions and 2 deletions
  1. 4 2
      tests/SharpGLTF.NUnit/gltf_validator.cs

+ 4 - 2
tests/SharpGLTF.NUnit/gltf_validator.cs

@@ -50,12 +50,14 @@ namespace SharpGLTF
 
             using (var p = System.Diagnostics.Process.Start(psi))
             {
+                // To avoid deadlocks, always read the output stream first and then wait.  
+                var mainReport = p.StandardOutput.ReadToEnd();
+
                 if (!p.WaitForExit(1000 * 10)) // wait for a reasonable timeout
                 {
                     try { p.Kill(); } catch { return null; }
-                }
+                }                
 
-                var mainReport = p.StandardOutput.ReadToEnd();
                 if (string.IsNullOrWhiteSpace(mainReport)) return null;
                 var report = ValidationReport.Parse(mainReport);