Warning of observer from scripted module in Slicer 5.0.3

To show this warning:
Modules-Developer Tools-Extension Wizard-Create Extension-Add Module
Open the module just created, switch to another module, then back to this module, you can see the warning:

/Applications/Slicer.app/Contents/bin/Python/slicer/util.py:2486: UserWarning: does not have observer
  warn('does not have observer')

It comes from:

    if self._parameterNode is not None:
      self.removeObserver(self._parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromParameterNode)

This warning shows in Slicer 5.0.3, but not in the previous versions.

Hello, I am seeing the same warning. Have you found a solution?

I think it has been fixed in the current version of Slicer (5.2.x or later).

Hi, thanks for the reply. I’m seeing the same warning on Slicer 5.2.1.

I thought BUG: Fix VTKObservationMixin regression · Slicer/Slicer@3a8deba · GitHub fixed these. @jcfr @Sunderlandkyl do you have any comments on this?

It’s an unrelated bug with the ScriptedModule template. Observers are already removed when exiting the module, however they are “removed” a second time when the user enters the module and setParameterNode() is called.

I’ve made a PR with a fix here: BUG: Fix scripted module template observer warning by Sunderlandkyl · Pull Request #6720 · Slicer/Slicer · GitHub

2 Likes

I am still getting this in Slicer 5.3.0 using Total Segmentator" in non-fast mode.

The fix that @Sunderlandkyl implemented in the module template had to be done in the TotalSegmentator module, too. It would be great if you could edit the file accordingly and if everything works well then send a pull request with the suggested changes.