Fixed shader compilation error handling 34/32534/3
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 18 Dec 2014 19:10:54 +0000 (19:10 +0000)
committerDavid Steele <david.steele@partner.samsung.com>
Mon, 5 Jan 2015 16:00:18 +0000 (16:00 +0000)
Dali::Vector cannot use operator[0] after a Reserve (it asserts),
unlike std::vector.

Changed error handling to use Begin() instead, which returns a pointer
to the reserved memory without asserting.

Fixed exception handling, which uses the same string without the length
check.

Change-Id: I2e0131aec6cec209f27ef0ea7f903c718cbc4193
Signed-off-by: David Steele <david.steele@partner.samsung.com>
dali/internal/render/shaders/program.cpp

index 8b145fc..1ef2600 100644 (file)
@@ -588,17 +588,17 @@ bool Program::CompileShader( GLenum shaderType, GLuint& shaderId, const char* sr
     DALI_LOG_ERROR("Failed to compile shader\n");
     LogWithLineNumbers(src);
 
-    Dali::Vector< char > szLog;
     GLint nLength;
     mGlAbstraction.GetShaderiv( shaderId, GL_INFO_LOG_LENGTH, &nLength);
     if(nLength > 0)
     {
+      Dali::Vector< char > szLog;
       szLog.Reserve( nLength );
-      mGlAbstraction.GetShaderInfoLog( shaderId, nLength, &nLength, &szLog[ 0 ] );
-      DALI_LOG_ERROR( "Shader Compiler Error: %s\n", &szLog[ 0 ] );
+      mGlAbstraction.GetShaderInfoLog( shaderId, nLength, &nLength, szLog.Begin() );
+      DALI_LOG_ERROR( "Shader Compiler Error: %s\n", szLog.Begin() );
     }
 
-    throw DaliException( "Shader compilation failure", &szLog[ 0 ] );
+    DALI_ASSERT_ALWAYS( 0 && "Shader compilation failure" );
   }
 
   return compiled != 0;