Create multiple render windows and got "failed at glDeleteFramebuffers 16 OpenGL errors detected" error when closing application

Hello everyone,

In our scenario, we use StackLayout to switch different user’s DICOM render image in QML.
For example:

StackLayout {
    id: multi_viewer
    Layout.preferredWidth: 800
    Layout.preferredHeight: 768
    Layout.alignment: Qt.AlignTop | Qt.AlignLeft
    currentIndex: 0

    GridLayout {
        columns: 1
        rows: 1
        columnSpacing: 10

        VTKRenderWindow {
            id: renderWin_0
            objectName: "renderWin_0"
        }

        VTKRenderItem {
            width: 395
            height: 368
            id: renderItem_0_0
            objectName: "renderItem_0_0"
            renderWindow: renderWin_0
        }

        Component.onCompleted : {
            viewerPresenter.init(0, renderWin_0, renderItem_0_0)
        }
    }

    GridLayout {
        columns: 1
        rows: 1
        columnSpacing: 10

        VTKRenderWindow {
            id: renderWin_1
            objectName: "renderWin_1"
        }

        VTKRenderItem {
            width: 395
            height: 368
            id: renderItem_1_0
            objectName: "renderItem_1_0"
            renderWindow: renderWin_1
        }

        Component.onCompleted : {
            viewerPresenter.init(1, renderWin_1, renderItem_1_0)
        }
    }

And use a button to switch card

Button {
    text: "Switch card"

    onClicked: {
        var index = multi_viewer.currentIndex
        multi_viewer.currentIndex = index === 0 ? 1 : 0
    }
}

It works fine. Once click button to switch render window and then close application, got error in VTK console. If don’t switch render window, no error thrown.

“OperationWorkbench.exe”(Win32): 已加载“C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16\comctl32.dll”。
ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F367290): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F368B00): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F366D40): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F368390): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (00000245929E1130): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

Any suggestions?

Thanks a lot!

@sankhesh