I need to get uniform names from ogl shaders(for simple editor project). I did not want to parse shaders by hands, so I writed some tricky code In Qt4 this code works just fine, but in Qt5 appears crash at ctx.create(). This crash deep in Qt Gui library, somewhere in QWindow…

Qt Code:
  1. QGLFormat fmt = QGLFormat::defaultFormat();
  2.  
  3. fmt.setVersion(2, 0);
  4.  
  5. fmt.setProfile(QGLFormat::CompatibilityProfile);
  6.  
  7. QWidget temp;
  8.  
  9. QGLContext ctx(fmt, &temp);
  10.  
  11.  
  12.  
  13. if (ctx.create())
  14.  
  15. {
  16.  
  17. ctx.makeCurrent();
  18.  
  19. QGLFunctions fncs(&ctx);
  20.  
  21. QGLShaderProgram prg(&ctx);
  22.  
  23.  
  24.  
  25. bool needToLink = false;
  26.  
  27. QGLShader vs(QGLShader::Vertex, &ctx);
  28.  
  29. if (!vertex.isEmpty() && (needToLink |= vs.compileSourceCode(vertex)))
  30.  
  31. prg.addShader(&vs);
  32.  
  33.  
  34.  
  35. QGLShader fs(QGLShader::Fragment, &ctx);
  36.  
  37. if (!fragment.isEmpty() && (needToLink |= fs.compileSourceCode(fragment)))
  38.  
  39. prg.addShader(&fs);
  40.  
  41.  
  42.  
  43. if (!needToLink)
  44.  
  45. return;
  46.  
  47.  
  48.  
  49. Q_ASSERT(prg.link());
  50.  
  51.  
  52.  
  53. const QGLContext *context = QGLContext::currentContext();
  54.  
  55.  
  56.  
  57. GLint total = -1;
  58.  
  59. fncs.glGetProgramiv( prg.programId(), GL_ACTIVE_UNIFORMS, &total );
  60.  
  61. for(GLint i = 0; i < total; ++i)
  62.  
  63. {
  64.  
  65. GLsizei nameLen = -1;
  66.  
  67. GLint num = -1;
  68.  
  69. GLenum type = GL_ZERO;
  70.  
  71. char name[100];
  72.  
  73. fncs.glGetActiveUniform( prg.programId(), i, sizeof(name)-1,
  74.  
  75. &nameLen, &num, &type, name );
  76.  
  77. name[nameLen] = 0;
  78.  
  79.  
  80.  
  81. uniforms << glsl_var_type(shaderParamType(type), name, num);
  82.  
  83. }
  84.  
  85. }
To copy to clipboard, switch view to plain text mode 

What you think about it? May be it is bug in library. Or it’s my bug. Anyway, how can I get uniform names – may be exists more beautiful solutions for this task?

PS
I post this question on qt-project forum but still no replies... So I decide copy my question here