ImGuiIntegration: Update reference to Context::_texture after moving Context - #62
Conversation
mosra
left a comment
There was a problem hiding this comment.
Thanks! Somehow I didn't realize this was missing.
| 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.
Maybe this should do ImGui::SetCurrentContext(_context); first, to ensure we don't update some other context.
There was a problem hiding this comment.
And then set it back later?
|
Oh and a test for this would be vital -- here it needs to check that&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>
mosra
left a comment
There was a problem hiding this comment.
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