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
ImGuiIntegration: Update reference to Context::_texture after moving Context #62
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Somehow I didn't realize this was missing.
@@ -130,6 +130,8 @@ Context::Context(NoCreateT) noexcept: _context{nullptr}, _shader{NoCreate}, _tex | |||
|
|||
Context::Context(Context&& other) noexcept: _context{other._context}, _shader{std::move(other._shader)}, _texture{std::move(other._texture)}, _vertexBuffer{std::move(other._vertexBuffer)}, _indexBuffer{std::move(other._indexBuffer)}, _timeline{std::move(other._timeline)}, _mesh{std::move(other._mesh)}, _supersamplingRatio{other._supersamplingRatio}, _eventScaling{other._eventScaling} { | |||
other._context = nullptr; | |||
/* Update the pointer to _texture */ | |||
ImGui::GetIO().Fonts->SetTexID(reinterpret_cast<ImTextureID>(&_texture)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should do ImGui::SetCurrentContext(_context);
first, to ensure we don't update some other context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then set it back later?
Oh and a test for this would be vital -- here
&b.atlasTexture() == io.Fonts.TexID . And also &c.atlasTexture() == io.Fonts.TexID , which will notify you that you need to do a similar change in the move assignment as well.
|
Codecov Report
@@ Coverage Diff @@
## master #62 +/- ##
===========================================
+ Coverage 74.13% 91.51% +17.37%
===========================================
Files 21 16 -5
Lines 901 542 -359
===========================================
- Hits 668 496 -172
+ Misses 233 46 -187
Continue to review full report at Codecov.
|
@mosra I updated the PR to reflect suggested changes. Note that I am restoring the original imgui context, which is backwards compatible and also tested by the tests to be the case. |
Signed-off-by: Squareys <squareys@googlemail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge right when the CIs finish.
Awesome, thanks! |
I'm so embarrassed, i can't believe i missed this! |
No problem, @Squareys missed a part of this also ... and I should be blamed for not noticing the issues in both PRs ;) |
Hi @mosra !
As mentioned on #61, the move constructor needs to update the pointer to
_texture
, otherwise rendering breaks because it uses the then deinitialized texture memory.Best,
Jonathan