[vtkusers] VTK+JAVA Crash in mouse events
Jeff Lee
jeff at cdnorthamerica.com
Wed Nov 19 06:45:41 EST 2003
Shyam Prakash wrote:
>Jeff,
> The program that I sent you was just to demonstrate my problem.
>Your idea of actors getting gc'ed while they are still in renderer could
>be a possibility. But then I can not convince my self how this could
>happen as the actor still has a reference to the renderer. Do you have
>any idea?
>
>
The way you coded it, as I recall, was to assign an ivar called actor =
new vtkActor() and then added it to the renderer. The next time you do
this, the previous actor has no more references (even though the
Renderer in c++ added a consumer, this is not the same as adding a
reference). Since you added the old one, but did not remove it, the
object was finalized while still in the renderer, causing the errors.
In short, the actor doesn't have a reference to the renderer, only a
list of consumers.
-Jeff
>Thanks
>Shyam
>
>-----Original Message-----
>From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf
>Of Jeff Lee
>Sent: Tuesday, November 18, 2003 8:06 PM
>To: Shyam Prakash
>Cc: vtkusers at public.kitware.com
>Subject: Re: [vtkusers] VTK+JAVA Crash in mouse events
>
>I think the main problem was that your actors were getting gc'ed while
>the mouse was moving. You should be careful to remove actors from the
>renderer which might be garbage collected for any reason. Furthermore,
>you were creating a new plane widget every time the action was triggered
>
>- was that your intent? If so, you need to remove the old one from the
>renderer first. In the future, if you see this type of behavior, it is
>almost guaranteed to be related to some object unwittingly being a
>candidate for garbage collection, and the object gets deleted while
>still in the renderer. I attached a better-behaving version of your
>code, but it may not be what you intended.
>-Jeff
>
>Shyam Prakash wrote:
>
>
>
>>Hello,
>>
>> I had encountered this problem earlier too. The program
>>suddenly crashes in mouseMove, mouseDrag,mousePress or mouseRelease
>>events with a message similar to the message given below.
>>
>>
>>
>>Current Java thread:
>>
>> at vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent_2(Native
>>Method)
>>
>> at
>>
>>
>>
>vtk.vtkGenericRenderWindowInteractor.MouseMoveEvent(vtkGenericRenderWind
>owInteractor.java:19)
>
>
>> at vtk.vtkCanvas.mouseDragged(vtkCanvas.java:209)
>>
>> at
>>
>>
>java.awt.Component.processMouseMotionEvent(Component.java:5182)
>
>
>> at java.awt.Component.processEvent(Component.java:4935)
>>
>>
>>
>>I am not sure what exactly could be the problem. I am using vtk 4.2.2
>>on Windows2k with jdk 1.4.1_02. Attached is a sample code. When I run
>>this code, it often crashes in my machine when I rotate the model
>>vigorously(in combination with resizing the window). My gut feeling is
>>
>>
>
>
>
>>it could be because of the presence of vtkImplicitPlaneWidget. Is
>>there anyway I can avoid this?
>>
>>
>>
>>Thanks
>>
>>Shyam
>>
>>
>>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
More information about the vtkusers
mailing list