Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LocalDispatcher : Use WeakMethod with
callOnUIThread()
This is probably neither here nor there in actual usage in the UI, but it is important for running the unit tests when the UI module has been imported. That's because `GafferUI.EventLoop` unconditionally installs a UIThreadCallHandler that just buffers the calls until an event loop is started. That prolonged Job lifetimes way outside of their associated tests, eventually causing this spooky action at a distance : ``` Traceback (most recent call last): File "/__w/gaffer/gaffer/build/python/GafferTest/BoxTest.py", line 1138, in testComputeNodeCastDoesntRequirePython node = CastChecker() File "/__w/gaffer/gaffer/build/python/GafferTest/BoxTest.py", line 1129, in __init__ self["out"] = Gaffer.IntPlug( direction = Gaffer.Plug.Direction.Out ) IECore.Exception: Traceback (most recent call last): File "/__w/gaffer/gaffer/build/python/GafferTest/BoxTest.py", line 1133, in isInstanceOf raise Exception( "Cast to ComputeNode should not require Python" ) Exception: Cast to ComputeNode should not require Python ``` How did that happen? Well, a Job contains a BackgroundTask, and `self["out"]` is a graph edit, and graph edits cancel background tasks, and the cancellation code does a `runTimeCast()` on the subject of the edit. So if a BackgroundTask exists thanks to EventLoop, then the cancellation code runs and does a `runTimeCast()` on `CastChecker`, which throws. It really would be better if EventLoop scoped its UIThreadCallHandler between `start()` and `stop()`.
- Loading branch information