Random crash on using renderText() of QGLWidget in Qt 5.5



  • Hi All,

    I am porting code from Qt 4.8.6 to Qt 5.5. I have been able to compile the code successfully but my GUI is crashing on using renderText(x, y, z, text, font) api of QGLwidget. It was working fine on Qt 4. Following is the sample code :-

    void SBaseView::renderNodeIds(QString str)
    {
        QStringList displayStrs = str.split(" ");
        visualizerTextFont = QFont( "Arial", 11, QFont::Normal, false);
        double offsetX = 2.0;
        makeCurrent();
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        qglColor(basicFontColor);
        GLdouble projection[16], modelview[16];
        GLint viewport[4];
        GLdouble x, y, z;
        glGetIntegerv(GL_VIEWPORT, viewport);
        glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
        glGetDoublev(GL_PROJECTION_MATRIX, projection);
        gluProject(position.x, position.y, position.z,
            modelview, projection, viewport, &x, &y, &z);
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glOrtho(0, viewport[2], 0, viewport[3], -1, 1);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
        glTranslated(x, y, z);
    
        double offsetY = 0;
        QFontMetrics fm(visualizerTextFont);
        int fontHeight = fm.height();
        offsetX += fm.width("  ");
        foreach(QString displayStr, displayStrs) {
            GLint originalAlignment = 1;
            glGetIntegerv(GL_UNPACK_ALIGNMENT, &originalAlignment);
            renderText(offsetX, -offsetY, 0, displayStr);
            glPixelStorei(GL_UNPACK_ALIGNMENT, originalAlignment);
            offsetY += fontHeight;
        }
    
        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
    
        glColor3ub(255, 255, 255);
        glEnable(GL_LIGHTING);
        glEnable(GL_DEPTH_TEST);
    }
    

    class SBaseView inherits QGLWidget.

    Please help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.