Tk Source Code

View Ticket
Login
2020-05-24
08:48 Closed ticket [1bb2f1d7]: ttk::treeview doesn't delete tags plus 6 other changes artifact: 755326fe user: fvogel
2020-05-08
15:46 Ticket [1bb2f1d7]: 4 changes artifact: 42bb7be2 user: fvogel
14:43
Fix [1bb2f1d7ab]: ttk::treeview doesn't delete tags. Patch from Emiliano Gavilan. check-in: 026c74c5 user: fvogel tags: bug-1bb2f1d7ab, tip-574
14:31
Fix [1bb2f1d7ab]: ttk::treeview doesn't delete tags. Patch from Emiliano Gavilan. Closed-Leaf check-in: 3c94d5fc user: fvogel tags: mistake
2020-05-04
21:39 Ticket [1bb2f1d7] ttk::treeview doesn't delete tags status still Open with 3 other changes artifact: 8b19ff80 user: emiliano
21:38 Add attachment treetags.test.diff to ticket [1bb2f1d7] artifact: 9d212cea user: emiliano
00:56 Add attachment treeview.patch to ticket [1bb2f1d7] artifact: 5c5f177e user: emiliano
00:55 Ticket [1bb2f1d7] ttk::treeview doesn't delete tags status still Open with 3 other changes artifact: 84def201 user: emiliano
2020-05-03
23:13 New ticket [1bb2f1d7]. artifact: 32c8b573 user: emiliano

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:

Thank you!

I have written the required TIP, see TIP #574

Also, I have committed your code and patch to branch 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: