widgets sample can crash when modifying a widget style (Issue #24656)

17 views
Skip to first unread message

PB

unread,
Jun 30, 2024, 8:25:48 AM (5 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed

In the widgets sample, when using the UI to modify the style of a widget, the current widget(s) is/are destroyed and then recreated.

On pages where there is more than one widget being shown (e.g., on the static text page), this can lead to the sample crashing or freezing. The reason is still the same as in #24487 (i.e., a8b4753):

  1. The widget page keeps a collection of pointers to its widgets.
  2. When modifying the widgets, the existing ones are destroyed, making those pointers in the collection invalid.
  3. After recreating each widget, WidgetsPage::NotifyWidgetRecreation() update function is called for the widget; however, this ends in WidgetsPage::SetUpWidget() where the whole page widgets collection is iterated and the stale pointers to the destroyed widgets accessed.

I am not sure how to best fix it at the sample level, instead of fixing each page, so for now I am just posting an Issue, not a PR. Perhaps using wxWeakRef instead of raw pointers in the widget collection would be a simple fix? But the current way, i.e., setting-up all the widgets each time one of them is (re)created, seems not ideal so a whole different approach may be better...


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24656@github.com>

PB

unread,
Jun 30, 2024, 5:18:29 PM (5 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed

After looking at a8b4753, it became clear that only two pages (static and spin) were affected by this bug (i.e., call NotifyWidgetRecreation() more than once when recreating widgets), so I opted for the simplest solution possible.

I think have encountered a freeze in some other page(s?) of the sample but the reason must be different, I don't remember which page it was, so I am closing this.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24656/2198760456@github.com>

VZ

unread,
Jul 3, 2024, 7:35:01 PM (2 days ago) Jul 3
to wx-...@googlegroups.com, Subscribed

Closed #24656 as completed via 19ec50b.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/24656/issue_event/13387415461@github.com>

Reply all
Reply to author
Forward
0 new messages