Tk Source Code

View Ticket
Login
Ticket UUID: 1bb2f1d7abab69d31e49a159465e213944c92f3
Title: ttk::treeview doesn't delete tags
Type: Bug Version: 8.7a4
Submitter: emiliano Created on: 2020-05-03 23:13:56
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2020-05-24 08:48:16
Resolution: Fixed Closed By: fvogel
    Closed on: 2020-05-24 08:48:16
Description:
ttk::treeview never releases or deletes tags, leading to a memory leak

Trigger script

package require Tk
ttk::treeview .t
set id 0
foreach n {100 1000 10000 1000 100} {
    for {set i 0} {$i < $n} {incr i} {
        set item [format {Item#%05d} [incr id]]
        .t insert {} end -text $item -tags $item
    }
    puts "Items: $n\nNumber of tags: [llength [.t tag names]]"
    foreach tag [.t tag names] {
        .t tag remove $tag
    }
}

"Items" and "Number of tags" should be equal but the last number is always increasing
User Comments: fvogel added on 2020-05-24 08:48:16:
TIP #574 now accepted, and implementation is merged into trunk.
Good job! Thanks Emiliano!

fvogel added on 2020-05-08 15:46:47: (text/x-fossil-wiki)
Thank you!

I have written the required TIP, see [http://core.tcl-lang.org/tips/doc/trunk/tip/574.md|TIP #574]

Also, I have committed your code and patch to branch [https://core.tcl-lang.org/tk/timeline?r=tip-574|tip-574].

emiliano added on 2020-05-04 21:39:08:
Attach a patch with a simple test

emiliano added on 2020-05-04 00:55:23:
The solution is to bring the tag facility in line with the one in the [text] widget, which provides [tag remove] and [tag delete] subcommands.
The first one allows removing the tag from a given range of characters (including all characters in the widget, using [$text tag remove $tag 1.0 end]). This, however, doesn't delete the tag information, and it still shows in the [tag names] subcommand. This is exactly the same functionality of the  [tag remove] in the treeview widget.
The [tag delete] subcommand performs a complete deletion of the tag information, including the removal of the tag from the widget and the tag configuration. It will not show in the [tag names] subcommand anymore.

Attached patch implements the [tag delete] subcommand for the ttk::treeview widget.

Attachments: