Hello everyone,
I’d like to know if a C++ loadable module can be loaded new without restarting the 3D slicer. I’d like to do it by clicking a PushButton in my moduleWidgetGUI.
No, we don’t support reloading C++ modules. It would be possible in theory, but since we are usually reloading modules to fix bugs, the chances of memory corruption would probably outweigh the benefits.
My suggestion is to put your GUI in python for rapid development and debugging and put your C++ code into a CLI module. Then you can rebuild and re-run the CLI without exiting Slicer. Plus that makes the C++ logic easier to test and reuse.
Reloading modules could be useful for quickly fixing errors found during monkey testing. However, we usually not develop C++ loadable modules this way, but we are a bit more disciplined, because C++ modules are usually infrastructure modules (that others modules rely on and therefore has to be very stable), and errors in C++ code can be easily catastrophic (make the application crash).
So, instead of quick iterations of randomly testing and reloading, usually we test a large part of the module using unit tests - without launching and manually operating Slicer. Application-level testing of various use cases are done using Python scripted self-tests. All these tests are also added to the list of automatic tests that are performed after each build to detect any regressions more quickly.
We of course still do random testing and there are a few tricks to make it more efficient. For example, we often load only an extension or a subproject in Visual Studio, so when you build, you don’t need to wait for build-check of the entire application (which can take tens of seconds) and we add a line to the .slicerrc.py file to automatically load a test scene when the application starts - saving a couple of clicks at each debugging session.
Hello, Andras and @pieper ! Thank you for the reply! I think I asked the question in a wrong way. I do not want to rebuild slicer. I’d like to restart a module with the already built Slicer. I do not want to make any changes to the C++ loadable module. All I want to do is restart the module with the same functionality (with the help of a PushButton), without making any changes and rebuilding the slicer.
Is it possible with some kind of extensions that already exists??
Best regards,
Anish
In this case, all you should need to do is close the scene and the module will reset, right?