kengineer Posted August 12, 2016 Report Posted August 12, 2016 It seems that I'm getting some hard faults upon setting GDISP_NEED_TEXT_WORDWRAP to true. I'm still working on figuring out the exact cause, but it appears it's when I do anything related to drawing labels, specifically in this function call: static bool mf_countline_callback(mf_str line, uint16_t count, void *state) { int *linecount = (int*)state; (*linecount)++; return TRUE; } The fault specifically happens immediately after calling (*linecount)++; Still looking into this but was wondering if anyone had any advice. FYI I'm using uGFX v2.4
kengineer Posted August 12, 2016 Author Report Posted August 12, 2016 I think I figured it out, there's a bug here. In mf_countline_callback, you are casting the void pointer as an int type which technically would vary by platform (int32_t on my platform). IF you go up a couple of function calls, you'll find: mf_wordwrap(font, cx, str, mf_countline_callback, &nbrLines); Where nbrLines is defined as a uint16_t. This is the problem, you're passing a uint16_t pointer in this case, and casting it as a 32 (at least on this platform) resulting in not incrementing the same part of memory we think we are. Upon modifying this, I don't get a hard fault anymore, so I'm going to see if the text wrap actually works now. Please verify this and move to the bug reports area.
kengineer Posted August 12, 2016 Author Report Posted August 12, 2016 Just confirmed, so here's the fix: static bool mf_countline_callback(mf_str line, uint16_t count, void *state) { uint16_t *linecount = (uint16_t*)state; (*linecount)++; return TRUE; }
Joel Bodenmann Posted August 12, 2016 Report Posted August 12, 2016 Thank you very much for bringing this to our attention and providing a corresponding patch. We just applied the patch to the repository: https://git.ugfx.io/uGFX/uGFX/commit/b9b555eae26a539ee71b30668f8e3fdb343e6ac1 Update: Blog post:
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now