MSceneMessage.kAfterOpen callback gets triggered multiple times

MSceneMessage.kAfterOpen callback gets triggered multiple times

lorena.rotherAR2EQ
Observer Observer
264 Views
1 Reply
Message 1 of 2

MSceneMessage.kAfterOpen callback gets triggered multiple times

lorena.rotherAR2EQ
Observer
Observer

I have a PySide2 UI that needs to be restarted when a new scene is loaded, so I added a kAfterOpen callback like this:

self.fileopen_callback = om.MSceneMessage.addCallback(om.MSceneMessage.kAfterOpen, partial(self.refresh_ui))
I register the callback in the showEvent and unregister it in the closeEvent.
Then, when I receive the callback I close the current UI and create a new instance. 
That works, however I'm running into an issue where the kAfterOpen callback gets triggered multiple times which causes my UI to "flash" several times when it starts, even though I'm just opening one file.
At first I thought maybe the multiple callbacks were due to having references in my file, but then I experienced the same issue with files that contained no references. The number of callbacks I get seems to be random, sometimes just one (as expected), some 2, some 3 and I can't figure out a way to reproduce it consistently. I was wondering if anyone has experienced this kind of issue, or has more information about what could be causing this callback to be emitted multiple times.
Thank you!
Lorena
0 Likes
265 Views
1 Reply
Reply (1)
Message 2 of 2

brentmc
Autodesk
Autodesk

Hi,

 

Could you be accidentally calling addCallback multiple times? (because I can't see any other way this would happen)

Brent McPherson
Principle Engineer
0 Likes