-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
MACGUI: Null pointer and empty chunks tests in mactext , change cursor restoration in getmaxwidth. #6538
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
base: master
Are you sure you want to change the base?
Conversation
The changes have nothing to do with the SCUMM engine. |
You’re absolutely correct, I apologise for the blunder . |
Just as it was written in the previous PR, you must follow our Commit Guidelines. Please fix the commit log messages. Also, you still must fix the excessive vertical space and in general follow our Commit Guidelines, particularly for indentation. |
I have made the fixes can you check now |
Can you check it now , i think i have removed most of the whitespaces |
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.
Added notes and questions
@@ -107,8 +120,7 @@ void MacTextCanvas::chopChunk(const Common::U32String &str, int *curLinePtr, int | |||
return; | |||
|
|||
// Now add rest of the chunks | |||
MacFontRun newchunk = _text[curLine].chunks[curChunk]; | |||
|
|||
MacFontRun newchunk = *chunk; |
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.
Please explain this change
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.
Earlier in the code the chunk was already defined as MacFontRun *chunk = &_text[curLine].chunks[curChunk]
So using *chunk instead of re-accessing _text[curLine].chunks[curChunk] avoids repeating the same lookup.
The new line makes it clear that we’re copying the same chunk we just created and worked with above. This makes the logic easier to follow. Since the function is already using the chunk pointer in multiple places, it's better to keep things consistent rather than mixing direct access and pointer usage.
ppos += _canvas.getLineCharWidth(i); | ||
ppos += _cursorCol; | ||
|
||
int absoluteCharOffset = 0; |
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.
What is the purpose of this renaming?
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.
The new name better describes the actual role of the variable: it stores the absolute character offset in the text buffer, from the beginning up to the cursor's position (_cursorRow, _cursorCol).Since the value is used to restore cursor position after rewrapping (with setMaxWidth()), calling it absoluteCharOffset makes its purpose immediately clear to future readers and maintainers.
Hey I have made and explained all the changes , can you please review it |
@dasbidyendu You still have to fix your commit log messages |
Hey , i am sorry for asking this but can i please get an example of how it should be , i have read the documentation but i can't figure out what to do , Sorry for asking. |
Update mactext-canvas.cpp |
Ok I’ll fix that one |
…t-canvas.cpp Added some checks to make sure The line continuations are not empty before adding them to the current line's word continuation to ensure consistency. Also added some comments on previous code. Made sure to append the chunks if it is within bounds. Added the newChunk as a pointer to the current chunk.
…r restoration issue in getmaxwidth. - Check for null pointer before handling any operations in getChunkNum function. - Check for empty chunks to avoid extra operations. - avoid signed/unsigned issue in chunk position. - avoid possible overflow in cursor restoration logic
Remove unnecessary vertical whitespaces from code.
I think i have fixed all the commit logs , please check them |
Check for null pointer before handling any operations in getChunkNum function.
Check for empty chunks to avoid extra operations.
avoid signed/unsigned issue in chunk position.
avoid possible overflow in cursor restoration logic