image delete
Brought to you by:
aldobu
When I'm about to destroy my label, I want to destroy my image , and that's when I get a crash.
proc onWidgetDestroy {img} {
image delete $img
}
package req Blend2d
set img [image create blend2d -format [list 100 100 PRGB32]]
label .l -image $img -borderwidth 0 -anchor nw
pack .l -padx 0 -pady 0 -expand 1 -fill both
bind .l <Destroy> {onWidgetDestroy $img}
I can't reproduce the crash on Windows. Everyting works as expected. (Blend2d 1.7)
Same on Mac (Intel) and Ubuntu.
The differencies between Mac/Windows/Linux are really minimals, just few lines in tkImgBlend2d.c., and up to now the only difference (solved few years ago) was that on Mac we had blue and red swapped ... Fixed with a bug-fix on the tcltk core.
I ask you because Blend2d it's not tested on the latest versions of TclTk, and regarding Mac, I only have an old Mac-Intel.
Please let me know these deatails, I will try to do more specific tests.
Yes , but I also have this issue on Windows
9.0.3
If it's very easy to compile your version, I could try to create a DLL in debug mode.
And see if there's any additional information.
Do you know of a place where I could read about how to compile tclBlend2D?
Downlod the tclBlend2d-devkit
https://sourceforge.net/p/irrational-numbers/code/HEAD/tree/pkgs/tclBlend2D-devkit/tags/1.7/
or
https://sourceforge.net/p/irrational-numbers/code/HEAD/tree/pkgs/tclBlend2D-devkit/tags/1.8/
The devkit also contains a prebuilt dll/dylib of the 'core' blend2d and also the include/stubs for TclTk (8.x and 9.x)
Note: release 1.8 introduces significant changes specifically in tkImgBlend2d.c, which should be the critical point where images are created and destroyed. I suggest to start with release 1.7
Quick instructions are in "HowToBuild.txt"
On Windows, I suggest to try first with
ms-build tcl-9
it should be enough (You will get the full deployable under the XBUILD directory)
If it's OK, clean the XBUILD directory before recompiling for debug:
set CFLAGS=/Zi /Od
set LFLAGS=/DEBUG
ms-build tcl-9
For debugging on MacOS
set CFLAGS=-g -O0
./build.sh tcl-9 arm64
Let me know if you have problems, it’s been years since I last compiled in debug mode.
I have successfully compiled in debug mode (on Windows, v1.7).
And look below when the window closes :
It would appear that nothing offers protection against this re-entry :
Well, I don’t know if this will help you, but it seems to match my crash.
Sorry, but I cannot reproduce your bug.
I'm on Windows , with TclTk 9.0.3 , using Blend2d 1.7
I also added this line to your script
after 2000 { puts "deleting label" ; destroy .l ; puts "done" }
and everything works as expected (no crash).
I suspect our TclTk 9.0.3 are not the same; mine is dated at the end of 2025, and I noticed that some parts of the Tk-core library have been updated recently.
More specifically tkImage.c was updated on February 2026, and this could be the reason of the your (new?) TclTk 9.0.3 crash.
Can you inspect the timestamp of your "wish90.exe" ?
Or, can you run your script with an older version of TclTk (< 9.0.3) ?
If my guess is correct, then something has changed in the Tk core.
My version is from December 2025
It’s the same for me – I’ve got no problem with that command, it’s only when I close the window.
The problem still persists (9.0.1)
It doesn't matter – in a way, that's just as well.
Thanks
Regards
Now I understand.
The problem is only when you destroy the root window "." !!! Correct ?
This imply that the whole application is terminated ...
The strange thing is that on my PC there's no crash, but the application takes 3..6 seconds to close.
Without the "bind .l <destroy> {onWidgetDestroy $img}", the application quits immediatly.</destroy>
This is a (weird) case that I should examine, and maybe fix!
In the meantime, I have this simple/silly workaround at Tcl level:
package require Tk
set ::TK ON
bind . <destroy> {set ::TK "OFF"} </destroy>
proc onWidgetDestroy {img} {
if {$::TK_STATUS eq "ON" } {
image delete $img
}
}
package req Blend2d
set img [image create blend2d -format [list 100 100 PRGB32]]
label .l -image $img -borderwidth 0 -anchor nw
pack .l -padx 0 -pady 0 -expand 1 -fill both
bind .l <destroy> {onWidgetDestroy $img}</destroy>
# UNCOMMENT THIS ..
# destroy .
Now the application (if launched by tclsh) should be already running, even without the wholeTk .
Yes !
Same , but I think there’s still a bug, because if you add a
putsafter thedeletecommand, you’ll never see it show up.I think version 1.8 fixes this bug.
See announce and download link at https://wiki.tcl-lang.org/page/Blend2d
Please, run a test on Mac-Silicon.
It works
Thank you