Qt World Summit: Submit your Presentation

QOpenGLWidget::update() stops working after a while

  • Hi

    I have an application that uses a QOpenGLWidget to draw a scene contained in framebuffer wich is previously rendered offscreen in another thread.

    When the scene has finished rendering, the rendering thread signals the main thread to update the QOpenGLWidget.

    My problem is that sometimes, the widget stops from being repainted (and never comes back to normal behavior)
    The update function continues to be called regularly
    The paintGL function is not called anymore
    However, resizing the main window (that contains the widget) triggers a repaint, and draw the scene just the way it should

    Do you have any idea of what could cause this problem ?
    There is no warning log of any kind when the update problem starts to occur

    How could i debug this ?


  • Lifetime Qt Champion


    Can you share your code ?

  • Hi,

    I am afraid i can't, I don't have the right to and it comes along with some elements of the system that would make the 'snippet' too large to be concise
    However there's a mistake in my post : the rendering thread does not signal the QOpenGLWidget to update() itself, it directly calls update() on it instead.
    This may cause a problem if update() is not thread safe as i thought it was. Is it ?

    Should I send a signal in order to call update() in the main thread ? Or repaint() ? Although the latter does not seem to be a good idea as i need the drawing to be as smooth as possible

  • Lifetime Qt Champion

    You should not call GUI function from a different thread. Signal and slots is the way to go.