# Slicer crashes on loading module (during UI buildup)

**URL:** <https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732>\
**Category:** Development\
**Created:** [July 20, 2017, 7:56pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732 "2017-07-20T19:56:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [July 20, 2017, 7:56pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732/1 "2017-07-20T19:56:05Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [July 20, 2017, 8:11pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732/2 "2017-07-20T20:11:59Z")

</div>

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](https://github.com/Slicer/Slicer/blob/dfe8e7e0da17ecf56ba965b6a592738085dfd608/Base/QTCLI/qSlicerCLIModuleUIHelper.cxx#L140), because returning NULL is part of the buttongroup interface. Try this patch:

```auto
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("");
 }

 //-----------------------------------------------------------------------------

```

---

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [July 20, 2017, 8:35pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732/3 "2017-07-20T20:35:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [July 20, 2017, 8:36pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732/4 "2017-07-20T20:36:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [July 21, 2017, 12:06pm UTC](https://discourse.slicer.org/t/slicer-crashes-on-loading-module-during-ui-buildup/732/5 "2017-07-21T12:06:37Z")

</div>

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