I ported a Qt GUI application from Qt4.8.6 to Qt 5.5.1

After porting GUI crashes randomly at renderText(x, y, z, font). Also sometimes text messes up, instead of letters and numbers bold black rectangles of different sizes are displayed. This code used to work fine with Qt 4.8.

My call stack is as follows :-


[Frames below may be incorrect and/or missing, no symbols loaded for ig7icd64.dll]




Qt5Guid.dll!QOpenGLFunctions::glDrawElements(unsig ned int mode=5, int count=60, unsigned int type=5123, const void * indices=0x000000e2cd2459c8) Line 730 C++
Qt5OpenGLd.dll!QGL2PaintEngineExPrivate::drawCache dGlyphs(QFontEngine::GlyphFormat glyphFormat=Format_A8, QStaticTextItem * staticTextItem=0x000000e2fe3a3dd0) Line 1902 C++

Qt5OpenGLd.dll!QGL2PaintEngineEx::drawTextItem(con st QPointF & p={...}, const QTextItem & textItem={...}) Line 1591 C++

Qt5Guid.dll!QPainterPrivate::drawTextItem(const QPointF & p={...}, const QTextItem & _ti={...}, QTextEngine * textEngine=0x0000000000000000) Line 6501 C++

Qt5Guid.dll!QPainter::drawTextItem(const QPointF & p={...}, const QTextItem & ti={...}) Line 6372 C++

Qt5Guid.dll!QPainter::drawText(const QPointF & p={...}, const QString & str={...}, int tf=0, int justificationPadding=0) Line 5913 C++

Qt5Guid.dll!QPainter::drawText(const QPointF & p={...}, const QString & str={...}) Line 5697 C++

Qt5Guid.dll!QPainter::drawText(int x=427, int y=175, const QString & s={...}) Line 884 C++

Qt5OpenGLd.dll!qt_gl_draw_text(QPainter * p=0x000000e2ca3c2ee0, int x=427, int y=175, const QString & str={...}, const QFont & font={...}) Line 4776 C++

Qt5OpenGLd.dll!QGLWidget::renderText(double x=8.0000000000000000, double y=0.00000000000000000, double z=0.00000000000000000, const QString & str={...}, const QFont & font={...}) Line 4960 C++

Pls help me in this. If anyone has faced similar issue. Text messed up issue is replicating on windows 8, cent os 6.6, ubuntu 14 while crash is replicating on windows.

Also note, There can be more than 1 QGLwidgets in the application. We have used a single instance of QGLcontext which is shared by all the QGLwidgets. Issue replicates when I add and delete few QGLwidgets, and try to render text on a new QGlwidget.