Skip to content

BUG: Changes the Remove Islands Morphology editor button to reference…

Sam Horvath requested to merge github/fork/AndrewBeers/remove-islands-fix into master

Created by: AndrewBeers

Resubmitted from a previous pull request with the previous "BUG:" prefix. Please excuse my Github stumbling..

**

Hello!

This is a tiny bug I stumbled upon. I am writing my own Python Slicer module, and imported the Editor widget within the context of my module. This works very well, except for the Remove Islands (Morphology Mode) button, which throws the following error when you call it:

Traceback (most recent call last):
  File "C:\Users\azb22\Documents\Software\SlicerNightly\Slicer 4.7.0-2016-10-19\lib\Slicer-4.7\qt-scripted-modules\EditorLib\RemoveIslandsEffect.py", line 76, in onApplyMorphology
    self.logic.removeIslandsMorphology()
  File "C:\Users\azb22\Documents\Software\SlicerNightly\Slicer 4.7.0-2016-10-19\lib\Slicer-4.7\qt-scripted-modules\EditorLib\RemoveIslandsEffect.py", line 259, in removeIslandsMorphology
    slicer.modules.EditorWidget.toolsBox.undoRedo.saveState()
AttributeError: 'module' object has no attribute 'EditorWidget'

This happens because RemoveIslands expects to be called from the Editor module, but I'm calling it from my own personal module. It searches for an instance of the EditorWidget and, not finding it, throws an error.

Other editor tools overcome this by instead using the slice self.undoRedo.saveState() (e.g.). I've added that change and tested it on the nightly version, and it seems to solve the issue.

Best, Andrew

Merge request reports

Loading