# \[bug\] Python-vtk BalloonWidget example does not work with vtk 9.2.2

**URL:** <https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103>\
**Category:** Development\
**Tags:** python\
**Created:** [December 7, 2022, 10:04am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103 "2022-12-07T10:04:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthieu](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/da6949/32.png) [@Matthieu](https://discourse.vtk.org/u/Matthieu)\
**Post date:** [December 7, 2022, 10:04am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/1 "2022-12-07T10:04:17Z")

</div>

Hello, when I try to run the [BalloonWidget example](https://kitware.github.io/vtk-examples/site/Python/Widgets/BalloonWidget/) I’ve got a SIGSEV error (it disappears if I comment the EnabledOn() line… but then it is not a very useful example !)

Other examples work well and I have installed vtk 9.2.2 via pip with python 3.10 in a virtual environment.

Do you know what could be the problem ?

EDIT : moving to development as it is more a bug I guess

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [December 9, 2022, 12:26am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/2 "2022-12-09T00:26:27Z")

</div>

I can confirm this is a crash in Linux. It works Ok in Windows.

In looking at the debugger it seems to be crashing at line 112 in the function `void FireTimers(vtkXRenderWindowInteractor* rwi)` in `vtkXRenderWindowInteractor.cxx `after the first iteration, so it is probably accessing a nonexistent timer (my guess). On line 120: `rwi->IsOneShotTimer(timerId)` is `false` which may also be a clue.

I have no idea what is going on. @ben.boeckel any ideas?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [April 24, 2023, 2:31am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/3 "2023-04-24T02:31:48Z")

</div>

@dgobbi? I’m not all that familiar with the X code…

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [April 24, 2023, 5:15am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/4 "2023-04-24T05:15:23Z")

</div>

The vtkHoverWidget (parent of vtkBalloonWidget) destroys the timer in its callback, and this results in an invalid iterator during the `for` loop in vtkXRenderWindowInteractor::FireTimers().

The loop in FireTimers() will have to be rewritten so that it doesn’t iterate over a container whose elements might be deleted during the loop. Should be an easy thing to fix.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [April 24, 2023, 1:32pm UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/5 "2023-04-24T13:32:27Z")

</div>

See [!10155](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10155) for a possible fix.

---

<div class="post-metadata">

**Author:** ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)\
**Post date:** [April 24, 2023, 3:58pm UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/6 "2023-04-24T15:58:33Z")

</div>

The CI missed this one because it happens only in interactive mode. It is reproducible by running `./bin/vtkInteractionWidgetsCxxTests TestBalloonWidget -I`.

@dgobbi’s change fixes the bug.

---

<div class="post-metadata">

**Author:** ![Matthieu](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/da6949/32.png) [@Matthieu](https://discourse.vtk.org/u/Matthieu)\
**Post date:** [May 11, 2023, 8:23am UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/7 "2023-05-11T08:23:17Z")

</div>

Thank you for your work ! Do you have an idea of when the fix will be available in python wheels ?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [May 11, 2023, 12:38pm UTC](https://discourse.vtk.org/t/bug-python-vtk-balloonwidget-example-does-not-work-with-vtk-9-2-2/10103/8 "2023-05-11T12:38:53Z")

</div>

There’s no plan for another 9.2 release at the moment.
