Changeset 1224


Ignore:
Timestamp:
Nov 18, 2008, 8:25:45 PM (16 years ago)
Author:
gah
Message:

added delete image callback to htmlviewer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/htmlviewer.tcl

    r785 r1224  
    5353
    5454    protected method _getImage {file}
    55     private common _icons        ;# maps file name => image handle
     55    protected method _freeImage {file}
     56    private common _file2icon        ;# maps file name => image handle
     57    private common _icon2file        ;# maps image handle => file name
    5658    private variable _dirlist "" ;# list of directories where HTML came from
    5759}
     
    320322# ----------------------------------------------------------------------
    321323itcl::body Rappture::HTMLviewer::_getImage {fileName} {
    322     if {[info exists _icons($fileName)]} {
    323         return $_icons($fileName)
     324    if {[info exists _file2icon($fileName)]} {
     325        set imh $_file2icon($fileName)
     326        return [list $imh [itcl::code $this _freeImage]]
    324327    }
    325328
     
    333336    foreach name $searchlist {
    334337        if {[catch {image create photo -file $name} imh] == 0} {
    335             set _icons($fileName) $imh
    336             return $imh
     338            set _file2icon($fileName) $imh
     339            set _icon2file($imh) $fileName
     340            return [list $imh [itcl::code $this _freeImage]]
    337341        }
    338342    }
    339343    return [Rappture::icon exclaim]
     344}
     345
     346itcl::body Rappture::HTMLviewer::_freeImage { imh } {
     347    if {[info exists _icon2file($imh)]} {
     348        image delete $imh
     349        set fileName $_icon2file($imh)
     350        unset _icon2file($imh)
     351        unset _file2icon($fileName)
     352    }
    340353}
    341354
Note: See TracChangeset for help on using the changeset viewer.