We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have this problem: I am editing the code in a class of my sketch but the changes are not registered by the sketch neither when I save the sketch nor when I re-run it. The only way to have the changes apply is to reload the entire sketch. Is this a new bug?
It might be related to the oscP5 library. This is the sketch:
add_library('oscP5')
class Listen(OscEventListener):
def oscEvent(_, m):
global col, msg
col = m.arguments()
print col
print 'Received oscEvent:', m.addrPattern(), col, m.typetag()
def setup():
size(400, 400)
background(255)
portR = 7407
oscR = OscP5(this, portR)
oscR.addListener(Listen())
def draw(): pass
whenever I edit the Listen class nothing happens unless i reload the sketch
Answers
Ok I figured it out. If I don't add the
def stop(): global oscR oscR.dispose()
function at the end, the OscEventListener keeps calling the function that I loaded the first time around. with the dispose() it will reload it each time.
@michizac, don't you remember I've found out that bug in your previous post?: ~:>
https://forum.processing.org/two/discussion/15995/receive-osc#Item_11
AFaIK, defining a function stop() to invoke dispose() wouldn't be necessary at all. :-B
My own example doesn't
def
any stop() nor invoke dispose() and it works alright: :>https://forum.Processing.org/two/discussion/15995/receive-osc#Item_8
Any smart library would automatically dispose() itself when the program exists after all.
But somehow, due to that bug in Python Mode, it's sorta workaround for when the sketch crashes. :-\"
BtW, no need to use
global
every time like you did for oscR within stop().Once any variable exists
in
globals(), we can access it everywhere w/oglobal
.Unless we need to assign
=
something to it. In this case,global
is obligatory for that variable. L-)http://py.Processing.org/reference/globals.html
https://docs.Python.org/2/library/functions.html?highlight=globals#globals