Tk Source Code

View Ticket
Login
Ticket UUID: 974600
Title: Gaps in Line sections
Type: Bug Version: obsolete: 8.5a2
Submitter: rmaris Created on: 2004-06-17 09:06:32
Subsystem: 05. Canvas Items Assigned To: hobbs
Priority: 7 High Severity:
Status: Closed Last Modified: 2026-10-23 10:55:24
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-10-23 10:55:24
Description:
Platform: windows (note: bug also appears in v8.4.6)
When I have created two or more lines on a canvas,  and 
these lines are "growing" by means of successive insert 
actions, gaps in line sections may occur under the 
following conditions (here two lines are supposed):

- Between any coordinate insert action of both lines the 
Tk Mainloop must have been active.
- Coordinates must be non-integer with non-zero 
fractional part (at least one of the coordinates).
- Only the LOWEST line (higher y-coordinate) is prone to 
this behaviour.

The lines will automatically refresh without gaps when 
another window will be moved over the lines, regardless 
whether it is a Tk window or not.

Attached is a PNG of an example output with two 
crossing lines. Interestingly: after the line crossing, all is 
well (but I also have obeyed further gaps in the line 
which is lowest).

Here's the test code that results in the attached output:

#console show
# test file to show line drawing errors
canvas .c -width 500 -height 200 -bg white 
-highlightthickness 0
#pack [button .b -text start -command {plotlines .c}]
pack .c

proc plotlines {w} {
    $w delete line
    set id1 [$w create line 0 0 0 0 -fill red -tags line]
    set id2 [$w create line 0 199 0 199 -fill blue -tags 
line]
    set n 0
    for {set x 0} {$x < 450} {incr x 2} {
    $w insert $id1 end "$x [expr {$n/5.0}]"
    $w insert $id2 end "$x [expr {199 - ($n/5.0)}]"
    incr n 4
    update
    }
}

plotlines .c

Note: the behaviour has been discovered in a datalogger 
application where several channels are supplying data 
via a com port. The data is retrieved event driven using 
a fileevent setup. The code above lacks this event drive. 
To achieve the erroneous result, an "update" command 
is used. The window must be visible during the plotlines 
call.
User Comments: serhiy.storchaka added on 2026-10-23 10:55:24:

Fixed in 8.6.13 by [1fe355fbe0], the fix for [5fb8145997]: inserting points into a line redrew too small a region, so with fractional coordinates parts of the new segments were clipped.


serhiy.storchaka added on 2026-09-22 09:54:29:

I cannot reproduce with 8.6.18, 9.0.5 and 9.1 on Windows 11 and on X11: with the script from the report, the two lines grown by successive inserts are pixel for pixel the same as the same lines created at once with all their coordinates.


dkf added on 2007-08-19 07:28:34:
Logged In: YES 
user_id=79902
Originator: NO

Confirmed with HEAD on WinXP. Still think it's a bounding box error, or maybe a bounding box coordinate rounding error...

When the canvas redraws itself properly, the gaps disappear.

rmaris added on 2004-06-17 20:42:11:
Logged In: YES 
user_id=968757

Please explain what you mean. I don't understand 
"bounding-box off-by-one".

BTW: would anyone be so kind to check this bug under unix?

dkf added on 2004-06-17 17:40:35:
Logged In: YES 
user_id=79902

Could it be a bounding-box off-by-one error?

rmaris added on 2004-06-17 16:06:32:

File Added - 90967: result.png

Attachments: