Merged
Conversation
Actually it was being cause by a failure to reset `(QPoint) TConsole::P_begin` and `(QPoint) TConsole::P_end` - which are used to record the selection in the event that the `TBuffer` was empty or for some other reason the selection was not found when called from `selectString(...)` which uses `(int) TConsole::select(const QString, int)`. There was also a Hindenbug lying in `TConsole::insertLink(...)` and `TConsole::insertText(...)` where if `buffer.buffer.empty()` was `true`, execution would then proceed to evaluate `buffer.buffer[0].empty()` which is undefined behaviour because there would not **be** a `buffer.buffer[0]`! This should close Mudlet#4634 - which I have reproduced in the current `development` branch code with the following function: ```lua function testCut() clearWindow() feedTriggers("This is a test line.\n") selectString(line, 1) cut() tempTimer(3, "feedTriggers(\"This is a second test line.\n\")") tempTimer(6, "selectString(line, 1) cut()") end ``` After the first time this is called, repeats will crash Mudlet when the 6 second delayed `selectString(line, 1) cut()` is called. One thing to note is that this code actually fails to follow the Wiki guidance for **[`selectString(...)`](https://wiki.mudlet.org/w/Manual:Lua_Functions#selectString)** which says "Note: To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes"! /claim Mudlet#4634 Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Closed
|
💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay. |
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
vadi2
approved these changes
Jan 1, 2024
vadi2
pushed a commit
to vadi2/Mudlet
that referenced
this pull request
Jan 5, 2024
Actually it was being cause by a failure to reset `(QPoint) TConsole::P_begin` and `(QPoint) TConsole::P_end` - which are used to record the selection in the event that the `TBuffer` was empty or for some other reason the selection was not found when called from `selectString(...)` which uses `(int) TConsole::select(const QString, int)`. There was also a Hindenbug lying in `TConsole::insertLink(...)` and `TConsole::insertText(...)` where if `buffer.buffer.empty()` was `true`, execution would then proceed to evaluate `buffer.buffer[0].empty()` which is undefined behaviour because there would not **be** a `buffer.buffer[0]`! This should close Mudlet#4634 - which I have reproduced in the current `development` branch code with the following function: ```lua function testCut() clearWindow() feedTriggers("This is a test line.\n") selectString(line, 1) cut() tempTimer(3, "feedTriggers(\"This is a second test line.\n\")") tempTimer(6, "selectString(line, 1) cut()") end ``` After the first time this is called, repeats will crash Mudlet when the 6 second delayed `selectString(line, 1) cut()` is called. One thing to note is that this code actually fails to follow the Wiki guidance for **[`selectString(...)`](https://wiki.mudlet.org/w/Manual:Lua_Functions#selectString)** which says "Note: To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes"! /claim Mudlet#4634 Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Actually it was being cause by a failure to reset
(QPoint) TConsole::P_beginand(QPoint) TConsole::P_end- which are used to record the selection in the event that theTBufferwas empty or for some other reason the selection was not found when called fromselectString(...)which uses(int) TConsole::select(const QString, int).There was also a Hindenbug lying in
TConsole::insertLink(...)andTConsole::insertText(...)where ifbuffer.buffer.empty()wastrue, execution would then proceed to evaluatebuffer.buffer[0].empty()which is undefined behaviour because there would not be abuffer.buffer[0]!This should close #4634 - which I have reproduced in the current
developmentbranch code with the following function:After the first time this is called, repeats will crash Mudlet when the 6 second delayed
selectString(line, 1) cut()is called. One thing to note is that this code actually fails to follow the Wiki guidance forselectString(...)which says "Note: To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes"!/claim #4634