# Slicer Preview crashes on slicer.util.resetSliceViews()

**URL:** <https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488>\
**Category:** Support\
**Created:** [December 3, 2024, 10:53am UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488 "2024-12-03T10:53:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [December 3, 2024, 10:53am UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488/1 "2024-12-03T10:53:55Z")

</div>

Slicer preview version: Slicer-5.7.0-2024-11-29-linux-amd64  
OS: Ubuntu 22.04.4 LTS

Slicer crashes ungracefully after calling `slicer.util.resetSliceViews()`

Here is the log:

```auto
Python console user input: slicer.util.resetSliceViews()
error: [/home/fryderyk/Downloads/Slicer-5.7.0-2024-11-29-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 3, 2024, 12:41pm UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488/2 "2024-12-03T12:41:14Z")

</div>

Thanks for the report. I can replicate this crash on the current preview build if I make the call before loading a volume. If I call it after loading a volume there is no crash.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [December 3, 2024, 12:46pm UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488/3 "2024-12-03T12:46:32Z")

</div>

I cannot replicate this on Windows before or after loading a volume.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 3, 2024, 1:20pm UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488/4 "2024-12-03T13:20:07Z")

</div>

I can replicate this on a local mac build. Here’s the stack trace:

```auto
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libvtkCommon-9.2.9.2.dylib 0x12e0d6b3f vtkCollection::AddItem(vtkObject*) + 63
1 libMRMLLogic.dylib 0x10effa51a vtkMRMLSliceLogic::FitSliceToFirst(int, int) + 362
2 libqMRMLWidgets.dylib 0x10cd61215 qMRMLSliceControllerWidget::fitSliceToBackground() + 53
3 libqMRMLWidgets.dylib 0x10cd146eb qMRMLLayoutManager::resetSliceViews() + 187
4 libqMRMLWidgets.dylib 0x10cda4bbd qMRMLLayoutManager::qt_metacall(QMetaObject::Call, int, void**) + 125
5 libqSlicerBaseQTGUI.dylib 0x10cb0d03a qSlicerLayoutManager::qt_metacall(QMetaObject::Call, int, void**) + 42
6 libPythonQt.dylib 0x1112e191a PythonQtCallSlot(PythonQtClassInfo*, QObject*, _object*, bool, PythonQtSlotInfo*, void*, _object **, void** , PythonQtPassThisOwnershipType*) + 762
7 libPythonQt.dylib 0x1112e3328 PythonQtSlotFunction_CallImpl(PythonQtClassInfo*, QObject*, PythonQtSlotInfo*, _object*, _object*, void*, void**, PythonQtPassThisOwnershipType*) + 2184
8 libPythonQt.dylib 0x1112e2233 PythonQtMemberFunction_Call(PythonQtSlotInfo*, _object*, _object*, _object*) + 195

```

I’ll see if I can debug and suggest a fix

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 3, 2024, 1:29pm UTC](https://discourse.slicer.org/t/slicer-preview-crashes-on-slicer-util-resetsliceviews/40488/5 "2024-12-03T13:29:48Z")

</div>

This fixes it: [BUG: Check for null pointer before fitting volume by pieper · Pull Request #8076 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/8076)
