[vtkusers] Multiple vtkRenderWindows - Error during cleanup: wglMakeCurrent failed in Clean()

Addison Elliott addison.elliott at gmail.com
Wed Apr 4 09:40:25 EDT 2018


Hello everyone,

I am receiving some errors on cleanup of my application. I am using Python
3.5.4 with PyQt5 and VTK 8.1 (Conda installed). I have a basic GUI with two
widgets used with VTK, each one instantiates a QVTKRenderWindowInteractor,
vtkRenderer and vtkRenderWindow like you'd expect. Here is a simplified
test case I have made: https://pastebin.com/EwuHZBFG. For the test case,
here is the output that is generated:

*destructor*
*SliceWidget_del1*
*SliceWidget_del2*
*SliceWidget_del3*
*SliceWidget_del4*

*SliceWidget_del1*
*SliceWidget_del2*
*ERROR: In ..\Rendering\OpenGL2\vtkWin32OpenGLRenderWindow.cxx, line 227*
*vtkWin32OpenGLRenderWindow (00000258F6471A00): wglMakeCurrent failed in
MakeCurrent(), error: The handle is invalid.*


*ERROR: In ..\Rendering\OpenGL2\vtkWin32OpenGLRenderWindow.cxx, line 87*
*vtkWin32OpenGLRenderWindow (00000258F6471A00): wglMakeCurrent failed in
Clean(), error: 6*

*SliceWidget_del3*
*SliceWidget_del4*

What this indicates is that on vtkRenderWindow.Finalize(), it is failing on
the *SECOND* destructor. So naturally, I removed the second render window
and found it works fine on applications with one render window.

After extensive debugging, I have found that this issue can be resolved if
vtkRenderWindow.Finalize() is called for both windows before the
interactor, renderWindow and renderer are destroyed. At lines 71 and 72 in
the test case if you uncomment them, then the code works fine.

In other words, here is a basic example
*# This WILL work*
*sliceWidget1.Finalize()*
*sliceWidget2.Finalize()*

*delete sliceWidget1 (This will delete interactor, renderer and
renderWindow)*
*delete sliceWidget2 (This will delete interactor, renderer and
renderWindow)*


*# This WILL NOT work*
*delete sliceWidget1 (This will delete interactor, renderer and
renderWindow)*
*sliceWidget1.Finalize()*
*delete sliceWidget2 (This will delete interactor, renderer and
renderWindow)*
*sliceWidget2.Finalize()*

Can anyone offer any assistance on where in VTK this may be causing an
issue? My initial thoughts is that upon destruction of one of the VTK
objects, the context device ID is destroyed and thus cannot be used in the
second Finalize() call. I don't have much familiarity in the VTK source
code, so I was fairly lost in trying to pinpoint the issue.

Thanks,
Addison
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180404/7fcc1d69/attachment.html>


More information about the vtkusers mailing list