Ticket UUID: | 2059415 | |||
Title: | ctext error when widget destroyed | |||
Type: | Bug | Version: | None | |
Submitter: | relaxmike | Created on: | 2008-08-19 10:16:00 | |
Subsystem: | None | Assigned To: | georgeps | |
Priority: | 5 Medium | Severity: | ||
Status: | Open | Last Modified: | 2008-08-20 14:13:29 | |
Resolution: | None | Closed By: | georgeps | |
Closed on: | 2008-08-19 21:19:58 | |||
Description: |
Hi, The following error message appears : invalid command name ".t._t" invalid command name ".t._t" while executing "$twin search -count length -regexp -- {([^\s\(\{\[\}\]\)\.\t\n\r;\"'\|,]+)} $si $end" (procedure "ctext::highlight" line 25) invoked from within "ctext::highlight .t 1.0 1.19" ("after" script) This error is reported in background. The reason for that bug is that "after" scripts are not cleaned after the destruction of the ctext widget. Looking at the ctext::highlight command, it is triggered by the following after sequence : after idle [list ctext::highlight $self $lineStart $lineEnd] in ctext::instanceCmd command. Other "after" script are associated with the command "ctext::comments" as well. A solution is to keep track of all after script generated, and to clean them when the widget is destroyed. For example, one can add a variable to keep track of the last after script associated with the highlight command : namespace eval ctext { variable lastafterscript "" } One can store the after ID with : set ::ctext::lastafterscript [after idle [list ctext::highlight $self $lineStart $lineEnd]] The Destroy method may contain : proc ctext::event:Destroy {win dWin} { after cancel $ctext::lastafterscript That solves the problem for one ctext only, and only for the last "after" highlight command. The real fix needs to store all after scripts, for the current ctext widget only. The bug can be reproduced with the unit test script in attachment. Regards, Michaƫl | |||
User Comments: |
relaxmike added on 2008-08-20 14:13:29:
Logged In: YES user_id=1573661 Originator: YES Thank you for that bug fix. By the way, thank you for ctext ! The suggested unit tests are the smallest possible amount of testing for the ctext package, that is : create/destroy. More tests (even if interactive) are available in the ctext_test*.tcl currently provided in the repository. Moreover, the tests are more testing the undo feature of the Tk text itself : this is because I discovered a bug in the Tk text, but I previously thought that it was a bug in ctext (I was wrong). The test ctext-1.2 is currently failing because of that bug (may be it is fixed in 8.5). I have one last question about the feature. Why exactly to delay the highlight after the insertion has been done ? Does that allow an improvment of the interactivity ? What kind of events may be to process between the insertion and the highlight ? georgeps added on 2008-08-20 04:19:58: Logged In: YES user_id=585068 Originator: NO I fixed this bug in the tcllib/tklib HEAD. ctext is now at revision 3.2. I used ctext::getAr and added 3 keys to the array used for storing information about ctext's per-widget state. So now this should all be handled by 3 catch {after cancel $configAr(...)} Please let me know if you experience further problems. Thank you for the unit test as well. I'll have to see about getting that integrated. relaxmike added on 2008-08-19 17:18:05: File Added - 289330: ctext.tcl Logged In: YES user_id=1573661 Originator: YES File Added: ctext.tcl relaxmike added on 2008-08-19 17:17:41: File Deleted - 289328: relaxmike added on 2008-08-19 17:17:13: File Added - 289329: ctext.test Logged In: YES user_id=1573661 Originator: YES File Added: ctext.test relaxmike added on 2008-08-19 17:16:00: File Added - 289328: ctext.test |