Slicer crashes on loading module (during UI buildup)

Operating system: Windows 10, 64 Bit
Slicer version:4.7.0-2017-07-07
Expected behavior: Show module UI
Actual behavior: Slicer crashes

Hi together, I am pretty new to Slicer (just started to work with Andrey Fedorov) and currently looking into the T1Mapping Extension ([https://github.com/QIICR/T1Mapping/tree/master/T1Mapping]). After it compiled fine it unfortunately crashes as soon as I try to load the module (select it under “All Modules”). I tracked the crash until “qSlicerCLIModuleUIHelper::updateUi” and from there it goes into “ButtonGroupWidgetWrapper::checkedValue()” for the IO parameter “modelName” which is a string-enumeration. Inside “ButtonGroupWidgetWrapper::checkedValue()” the call to “this->ButtonGroup->checkedButton()” returns a NULL pointer which causes the following assert to fail and crash the app.

I cannot figure out what is wrong. The T1Mapping source code is unaltered. I did notice that the string-enumeration did not declare a default, which I thought could be a problem, but adding a default in the xml didn’t change anything.

I would be happy if someone has an idea what could be wrong.

Michael

The simple fix is to set a <default> element for the modelName string-enumeration. The correct fix for Slicer core is probably to remove this assert, because returning NULL is part of the buttongroup interface. Try this patch:

diff --git a/Base/QTCLI/qSlicerCLIModuleUIHelper.cxx b/Base/QTCLI/qSlicerCLIModuleUIHelper.cxx
index 651163024..5f3bb93c7 100644
--- a/Base/QTCLI/qSlicerCLIModuleUIHelper.cxx
+++ b/Base/QTCLI/qSlicerCLIModuleUIHelper.cxx
@@ -137,8 +137,11 @@ QButtonGroup* ButtonGroupWidgetWrapper::buttonGroup()const
 QString ButtonGroupWidgetWrapper::checkedValue()
 {
   QAbstractButton* button = this->ButtonGroup->checkedButton();
-  Q_ASSERT(button);
-  return button->text();
+
+  if (button)
+    return button->text();
+  else
+    return QString("");
 }

 //-----------------------------------------------------------------------------
1 Like

Thank you for the answer. It works now! I actually had tried to add the <default> element before, but only build the solution, while it apparently required a complete re-build to make the changes in the xml take effect.

1 Like

If you want to submit that patch for your first PR to Slicer, please go for it. (also, hi neighbor :wave:)

2 Likes

OK, I’ll try to do that, good exercise, thx :slight_smile:

2 Likes