This is a known issue with Write nodes inside of Gizmos (already logged as bug 
#21137). If you change any of the format-dependent knobs on the Write and then 
change its format without resetting those knobs to their default states, the 
format-specific knobs aren’t destroyed cleanly, and as soon as you touch 
anything else, Nuke will segfault. The workaround is to keep track of any 
format-specific knob changes you make and be sure to reset those knobs BEFORE 
changing the format again.

-Nathan



From: Björn Fredriksson 
Sent: Wednesday, November 16, 2011 6:36 AM
To: [email protected] 
Subject: [Nuke-python] Crashes when wrapping a write node in a gizmo.

Hi all, 

I've got a gizmo that has an internal write node. And to limit the options 
available I elected not to link in the file types from the underlying Write 
node, instead I use python callbacks to set these according to whatever the 
user sets with a pulldown-knob. The callback hides and unhides some options for 
the formats based on that pulldown choice. And since the same knobs are not 
available with all formats (e.g. 'datatype') I only set them on the Write node 
if the correct file format has been set.

The problem is, if I switch between the sgi or tga format and exr a few times, 
and then change datatype Nuke crashes without warning. My first guess is if 
this is some race condition between me trying to set up the knob-values while 
the c++ plugin for the file format is not yet loaded, but that seems to not be 
the case. 

Any ideas?

Simplified example to reproduce:


Gizmo called testGizmo:
------------------
#! 
/Applications/Nuke6.1v2/NukeX6.1v2.app/../Nuke6.1v2.app/Contents/MacOS/Nuke6.1v2
 -nx
version 6.1 v2
Gizmo {
addUserKnob {20 Test}
addUserKnob {41 channels T Write1.channels}
addUserKnob {41 assetColorspace l "Colorspace" T Write1.colorspace }
addUserKnob {4 fileTypes l "File type" M {dpx exr jpeg sgi targa tiff}}
addUserKnob {4 exr_bytes l "Data type" M {"16-bit half" "32-bit float"} }
}
Input {
  inputs 0
  name Input1
  xpos 16
  ypos -89
}
Write {
  channels rgba
  file test.####.exr
  file_type exr
  checkHashOnRead false
  version 1
  name Write1
  xpos 16
  ypos -17
}
Output {
  name Output1
  xpos 16
  ypos 51
}
end_group
-------------------


callback (in menu.py):
------------------------
def testGizmoChanged():
    node = nuke.thisNode()
    
node.node('Write1').knob('file_type').setValue(node.knob('fileTypes').value())
    if node.node('Write1').knob('file_type').value() == "exr":
        node.knob('exr_bytes').setVisible(True)
        
node.node('Write1').knob('datatype').setValue(node.knob('exr_bytes').value())
    else:
        node.knob('exr_bytes').setVisible(False)

nuke.addKnobChanged(testGizmoChanged, nodeClass='testGizmo')
-----------------------


// Björn

-- 
Björn Fredriksson | Head of 2D | Swiss International AB
Sankt Eriksgatan 48 B, 112 34 Stockholm, Sweden
ph +46 8 662 24 60, NEW CELL +46 721 666 011



--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to