Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when object children iterator is invalidated #90

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

MelodicsPavol
Copy link
Contributor

Calling QQmlContext::nameForObject can have side effects, creating new child objects via property read functions.

Reproduction steps:

  1. in examples/Basic/main.qml change Window to ApplicationWindow
  2. in examples/Basic/main.cpp MyTests::executeTest() add a line std::cout << existsAndVisible(spix::ItemPath("mainWindow/Button_X"));

ApplicationWindow has screen property, accessing which adds a new QQuickScreenInfo object into children list. If this happens during list iteration in range loop, the iterator will be invalidated. Using index based for loop will avoid crash scenario.

Reproducible with Qt 6.2 LTS.

Calling QQmlContext::nameForObject can have side effects, creating new child objects via property read functions.
@walterbrebels
Copy link
Contributor

Spix server crashes due to this issue, is this fix ok to merge?

@faaxm faaxm closed this Dec 13, 2023
@faaxm faaxm reopened this Dec 13, 2023
@faaxm faaxm merged commit 63b5481 into faaxm:master Dec 14, 2023
21 checks passed
@faaxm
Copy link
Owner

faaxm commented Dec 14, 2023

Thank you @MelodicsPavol !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants