[vtk-developers] A weird 6.x specific bug with ModifiedEvents
David Gobbi
david.gobbi at gmail.com
Mon Apr 14 12:08:20 EDT 2014
On Mon, Apr 14, 2014 at 9:35 AM, Prabhu Ramachandran
<prabhu at aero.iitb.ac.in> wrote:
> Hi everyone,
>
> I just discovered a weird bug with VTK 6.1 and 6.0 that doesn't happen with
> VTK 5.x. Here is a tiny Python script:
>
> ##################################################
> import vtk
> def f(o, e):
> print e, o.GetAmbientColor(), o.GetColor(),
> print o.GetDiffuseColor(), o.GetSpecularColor()
>
> p = vtk.vtkProperty()
> p.AddObserver('ModifiedEvent', f)
> p.SetColor(0,0,0)
> print p.GetColor()
> ##################################################
>
> If you comment out the AddObserver line, everything works correctly but with
> it, you can never set the color of the property! This doesn't seem to be
> specific to Python and happens with a small C++ example as well.
I can confirm, I saw exactly what you reported. Then I changed the Set
method to SetAmbient(0.1234) and the problem disappeared, everything
worked fine.
Then, I tried with both SetColor and SetAmbient, and saw something that
looks Very Bad:
##################################################
import vtk
def f(o, e):
print e, "Color:", o.GetColor()
print e, "Ambient:", o.GetAmbient()
p = vtk.vtkProperty()
p.SetColor(0,0,0) # clear value
p.SetAmbient(0) # clear value
p.AddObserver('ModifiedEvent', f)
print "SetColor(0.25,0.5,0.125)"
p.SetColor(0.25,0.5,0.125)
print "SetAmbient(0.1234)"
p.SetAmbient(0.1234)
##################################################
The output was:
SetColor(0.25,0.5,0.125)
ModifiedEvent Color: (0.0, 0.0, 0.0)
ModifiedEvent Ambient: 0.0
SetAmbient(0.1234)
ModifiedEvent Color: (0.027461278262417663, 0.054922556524835325,
0.013730639131208831)
ModifiedEvent Ambient: 0.1234
So as far as I can tell, catching the ModifiedEvent results in some sort
of memory corruption. I'm compiling with llvm-gcc on OS X 10.6.
David
More information about the vtk-developers
mailing list