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

Fixes #82 crash on startup when no project is previously selected. #93

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

jeady
Copy link

@jeady jeady commented Apr 5, 2024

Fixes #82

This bug was introduced in 8f1e04e by changing struct RecentProject to class ProjectDefinition. By making this type a reference, the default value is now null, instead of an object with all fields set to default, which leads to crashes when it is dereferenced.

This fix makes the SetProject() function accept null as an arugment and then configures all variables as they would have been before. This continues to run the intialization code. Alternatively, we could skip the call to SetProject() entirely -- with my limited understanding of the code base, I don't know if that's safe or not. I don't feel strongly about the approach, happy to do either.

#89 also fixes this by skipping the call to SetProject() if project is null, but I think it makes sense to decouple this quick bug fix from the rest of the feature work there.

… selected.

This bug was introduced in shpaass@8f1e04e by changing `struct RecentProject` to `class ProjectDefinition`. By making this type a reference, the default value is now null, instead of an object with all fields set to default, which leads to crashes when it is dereferenced.

This fix makes the SetProject() function accept null as an arugment and then configures all variables as they would have been before. This continues to run the intialization code. Alternatively, we could skip the call to SetProject() entirely -- with my limited understanding of the code base, I don't know if that's safe or not.
@jeady jeady changed the title Fix crash on startup (issue #82) when no project is previously selected. Fixes #82 crash on startup when no project is previously selected. Apr 5, 2024
@jeady
Copy link
Author

jeady commented Apr 5, 2024

Ah I see now that #89 is already approved, I thought it required more review. In that case, happy to revert this PR.

@veger
Copy link
Collaborator

veger commented Apr 5, 2024

Thanks for your contribution 👍

I suspect #89 gets merged soon, technically @shihan42 can merge already, but I think they are waiting on @have-fun-was-taken.
When it is merged this one becomes obsolete, or are there left over benefits? If so, I am happy to review.

@shihan42
Copy link
Collaborator

shihan42 commented Apr 6, 2024

@jeady Thank you for your contribution. And yeah, @veger is right, I wanted to wait on @have-fun-was-taken, since although I have merging rights, they are the owner of the repo. But this is small enough that I dare to take a shortcut 😉

There was some discussion about the entire thing on Discord. "Dorus" and "Just Monika" raised some valid concern about the semantics in the current implementation. They mentioned that it would make more sense to make sure that SetProject() can handle any return value of FirstOrDefault().

Typically, I would argue that the SetProject() call should only occur if a project truly exists. Semantically, that's what I would expect. However, upon closer examination of the method, I noticed that there's actually some initialization happening.

So I decided to merge your PR, which hardens SetProject(), and then adjust my code accordingly.

Copy link
Collaborator

@shihan42 shihan42 left a comment

Choose a reason for hiding this comment

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

Regardless of the state of the input parameter, after this code the project definition is in a valid state and ready to be used.

@shihan42 shihan42 merged commit 4fa2b2e into shpaass:master Apr 6, 2024
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.

Crash off of first install on 0.6.2
3 participants