[vtkusers] Java remove vtkImageViewer2 not working
Jim Peterson
jimcp at cox.net
Thu Dec 2 23:10:53 EST 2010
Jonathan Morra wrote:
>
> I have a java swing JPanel that contains another JPanel that contains
> a vtkRenderWindowPanel which is hooked up to a vtkImageViewer2. In the
> course of my program I want to remove the inner JPanel from the outer
> JPanel with JPanel.remove(). I then want to add the inner JPanel to a
> different outer JPanel. However when I do this VTK throws the
> following exception
>
> ERROR: In ..\..\src\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 247
> vtkWin32OpenGLRenderWindow (00000004C8E4830): wglMakeCurrent failed in
> MakeCurrent(), error: The handle is invalid.
>
> This seems like a very simple swing operation that I'm trying to do,
> but it's failing. Does anyone know what I'm doing wrong?
> Thanks
>
Jonathan,
you do understand that the vtk classes are JNI interfaces to the shared
library version of vtk. I suspect you are causing Java to free resources
that are still referenced by the memory instantiated by the still active
structures outside Java in vtk. Without an example it is pretty hard to
try to visualize the java and native system memory from your
description. What you are doing might be sensible with all java objects,
but when JNI objects are involved memory references may not be as clear
as desired. are not always completely in sync.
Chances are if you coded the same kind of operation in C++ the make
current routine would have detected the different potential interaction
source and issued this message: (from the MakeCurrent() function in
vtkWin32OpenGLRenderWindow.Cxx)
if(this->IsPicking && current)
{
vtkErrorMacro("Attempting to call MakeCurrent for a different window"
" than the one doing the picking, this can causes
crashes"
" and/or bad pick results");
}
Unless you want to post an example, I would say "If it hurts, don't do
that".
Hope that helps,
Jim
More information about the vtkusers
mailing list