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

Clearing fonts input data and tex data now triggers IsBuilt() assertion #4455

Closed
Flix01 opened this issue Aug 21, 2021 · 4 comments
Closed

Comments

@Flix01
Copy link

Flix01 commented Aug 21, 2021

Version/Branch of Dear ImGui:

Version: 1.84.1
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: custom
Compiler: g++
Operating System: Ubuntu 20.04

Issue

Not a big deal to be honest.
While updating my code to the current version, I've just discovered that the two lines of code I used to reduce font memory can't be used anymore, because they trigger an assertion.

    ImGuiIO& io = ImGui::GetIO();
    // Here I load the font (not shown)
    IM_ASSERT(io.Fonts->Fonts.Size>0);
    IM_ASSERT(io.Fonts->TexReady);
    IM_ASSERT(io.Fonts->IsBuilt());
    // OK here

#   ifndef IMGUIBINDINGS_DONT_CLEAR_INPUT_DATA_SOON
    // Cleanup (don't clear the input data if you want to append new fonts later)    
    io.Fonts->ClearInputData();
    io.Fonts->ClearTexData();
#   endif //IMGUIBINDINGS_DONT_CLEAR_INPUT_DATA_SOON

   IM_ASSERT(io.Fonts->IsBuilt());  // triggers here

The solution is just to hard-code the IMGUIBINDINGS_DONT_CLEAR_INPUT_DATA_SOON definition, unless it's just an
assertion problem.

Is that memory saving feature still supported?

@ocornut
Copy link
Owner

ocornut commented Aug 21, 2021

I believe ClearInputData() shouldn't clear TexReady...

@ocornut
Copy link
Owner

ocornut commented Aug 21, 2021

Linking to #3487 we should add tests for those two cases.

@Flix01
Copy link
Author

Flix01 commented Aug 21, 2021

OK, good to know it's still supported. In the meantime, I can just manually set TexReady to true.
Thanks for your quick feedback. Feel free to close it whenever it's the case.

@ocornut
Copy link
Owner

ocornut commented Aug 24, 2021

Pushed a fix for this 4a7c21d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants