Repository navigation
fix: reset Cores created by the GUI when it closes - #168
Conversation
Proper device shutdown requires calling CMMCore.reset() before terminating the application. This solution ensures that any CMMCore created by the application is reset before the main GUI closes. Note that callers passing a CMMCore instance to MicroManagerGUI or create_mmgui are responsible for cleaning it up (they may want to continue using that instance after the GUI closes)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
+ Coverage 81.87% 82.69% +0.82%
==========================================
Files 29 29
Lines 1810 1815 +5
==========================================
+ Hits 1482 1501 +19
+ Misses 328 314 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I'm ok with this... but it smells a little bit like the thing we just spent a long time debugging (see pymmcore-plus/pymmcore-plus#572 and related issues). this one is probably safer because it's a higher level object cleaning up the core... but, I'll point out that the C++ destructor of CMMCore itself calls reset. So, it's not strictly necessary for the user to call |
@marktsuchida and I were testing a new device adapter on one of our scopes and found that devices were not being shutdown (specifically that (a) behavior programmed into shutdown was not being observed and (b) that no log messages relating to unloading devices were present in the core log) when we pressed the close button. Then I was able to replicate this on my own machine with the demo config. Yeah, I was a bit suprised too that the CMMCore destructor does call this, but it's possible that with GUI shutdown behavior the C++ destructor doesn't get called in time? |
|
Arg. That's annoying :) I guess we'll just have to use belt and suspenders then |
Proper device shutdown requires calling CMMCore.reset() before terminating the application. This solution ensures that any CMMCore created by the application is reset before the main GUI closes.
Note that callers passing a CMMCore instance to MicroManagerGUI or create_mmgui are responsible for cleaning it up (they may want to continue using that instance after the GUI closes)