Skip to content

Generator class holds a reference to an analyser model#1439

Open
hsorby wants to merge 7 commits into
cellml:mainfrom
hsorby:issue1395
Open

Generator class holds a reference to an analyser model#1439
hsorby wants to merge 7 commits into
cellml:mainfrom
hsorby:issue1395

Conversation

@hsorby

@hsorby hsorby commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@hsorby hsorby requested review from agarny and nickerso July 6, 2026 08:13
nickerso
nickerso previously approved these changes Jul 6, 2026

@agarny agarny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The original issue (#1395) talks about the Generator class "either hold[ing] a weak pointer to the AnalyserModel or drop[ping] its reference when it has finished with it`. I feel like holding a weak pointer would be better. So, what was the rationale for taking the other option?

Comment thread src/generator.cpp
Comment thread src/generator.cpp
Comment thread tests/generator/generator.cpp Outdated
Comment thread tests/generator/generator.cpp Outdated
Comment thread tests/generator/generator.cpp Outdated
@hsorby

hsorby commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Just holding a weak pointer would mean checking it constantly everytime you wanted to use it as it could be deleted at any time. By holding a shared pointer you are certain to be holding the object until you are finished with it, which we do by resetting the pointer when we are finished using it for generating code.

@agarny

agarny commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Just holding a weak pointer would mean checking it constantly everytime you wanted to use it as it could be deleted at any time. By holding a shared pointer you are certain to be holding the object until you are finished with it, which we do by resetting the pointer when we are finished using it for generating code.

Indeed, fair enough!

@agarny agarny requested a review from nickerso July 6, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants