Skip to content

C++: make sure we do not crash if a Model::row_data returns nullopt #8568

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

Merged
merged 1 commit into from
May 30, 2025

Conversation

ogoffart
Copy link
Member

Rust had a test for it, but C++ not yet

Reported on https://chat.slint.dev/public/pl/pcqefc3fbff3xfuio3uhp58ate

@ogoffart ogoffart requested a review from tronical May 28, 2025 15:11
c.state = State::Clean;
if (auto data = model->row_data(index)) {
(*c.ptr)->update_data(index, *data);
c.state = State::Clean;
Copy link
Contributor

@ubruhin ubruhin May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert here, but wouldn't it make more sense to move this line outside the if block so the state is set to clean even if the model returns nullopt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

@ogoffart ogoffart merged commit 5030431 into master May 30, 2025
40 checks passed
@ogoffart ogoffart deleted the olivier/cpp3 branch May 30, 2025 13:47
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