MultiThreaded GUI application



  • Hi All,
    Im getting an error like XLib:sequence Failed, X Error: BadAccess X Error: BadLenght
    and some times QGLContext:makecurrent Failed.And all these problems raised after introducing the threads. In above mentioned error list some of them ll rise because if we are trying to do some GUI related operation in the worker thread other then Main GUI thread,but in my case im doing all GUI related operation in Main thread only.But still… Can some one help me to solve these problems.
    Thank U.

    [Moved to General and Desktop since more people are going to see it there, Tobias]



  • It is really heard to say anything from this information.
    Do you have some example code? small test app that shows (only) the problem?



  • Hi, Thanks..Actually this is quiet bit big application so i myself don't know which portion of code is raising the problem,but i can explain what im doing.
    In socket im receiving the data which is thread and some calculation im doing in separate thread and painting is done in some other class which is there in main thread.
    Previously it was working fine but data reception is very fast and data was skipping so i introduced thread for receiving as well as for doing calculation also.So started to get errors like as shown above. Something like :
    XLib: Unexpected async reply after sometime it gives
    XLib:Sequence failed something like this.



  • Check that you function calls and signal/slot connections are really triggering all your GUI operations to happen in the main thread.



  • Ya im confirm about that. Problem is coming when i do PixelBuffer makecurrent(). This is the piece of code whr im getting problem:

    @
    flushData()
    {
    pixelBuffer->makeCurrent();
    glClearColor(0.5,0.5,0.5,255);
    glClear(GL_COLOR_BUFFER_BIT);
    }
    @
    Where pixelBuffer is the QGLPixelBuffer object.

    And following where im initalizing my QGLWidget:
    @
    setWidget(QWidget* w)
    {
    if( QGLPixelBuffer::hasOpenGLPbuffers() )
    {
    QGLWidget* glw = qobject_cast<QGLWidget*>(w);
    if( glw )
    {
    QGLFormatformat(QGL::Rgba|QGL::AlphaChannel,1);//
    pixelBuffer = new QGLPixelBuffer(d->size, d->size, format, glw);

        }
        else
            pixmap = new QPixmap(d->size, d->size);
    }
    else
        pixmap = new QPixmap(d->size, d->size);
    
    // Now initialize the paint device
    if(pixelBuffer)
    {
        pixelBuffer->makeCurrent();
        glViewport(0, 0, d->size, d->size);
       glClearColor(0.5,0.5,0.5,255);
        glClear(GL_COLOR_BUFFER_BIT);
    
        textureId = pixelBuffer->generateDynamicTexture();
    

    #ifndef Q_WS_X11
    pixelBuffer->bindToDynamicTexture(textureId);
    #else
    pixelBuffer->updateDynamicTexture(textureId);
    #endif

        ((QGLWidget*)(w))->makeCurrent();
    
        dataPaintDevice = pixelBuffer;
    

    }
    @
    And one more thing that flushData() function if i call initially then no problem but after when start to read the data from the socket then problem ll rise.

    Edit: please use @ tags to delimit code blocks to make it more readable [ZapB]


Log in to reply
 

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