Concurrent calls to slicer app processEvents() crashing slicer

Slicer is randomly crashing if I register a callback to the dicom indexer and make my callback call

self.indexer = ctk.ctkDICOMIndexer()
self.indexer.connect("progress(int)", updateProgress)
self.indexer.addDirectory( db, inputDir )

The callback calls processEvents:

def updateProgress():

I suspect that the callback is being called concurrently and crashing slicer by calling processEvents concurrently. If I use a mutex for preventing the call to processEvents by more than one thread, it works.

Makes sense - should be used very carefully and only when absolutely needed.

1 Like

If you call processEvents() inside an event handler, you may get into infinite recursion (and there might be other issues), so don’t do it.

Since ctkDICOMIndexer can run in non-blocking mode (set indexer.backgroundImportEnabled=True), it is not necessary to call at all. If the main thread is not blocked then all events are processed automatically. You can use the application while the import in the background is running; or show a popup window to block the user from wandering away.

You may also use the DICOM module’s indexer, which shows the progress in the DICOM browser and does not block the application at all (as it is done in this test/example).

1 Like