Author: Christian Lopes
Date: 2011-05-03 13:17:37 -0700 (Tue, 03 May 2011)
New Revision: 24906

Modified:
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/ImageCache.as
Log:
Calling BitmapData.dispose() on node images, to prevent memory leaks.

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/ImageCache.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/ImageCache.as   
    2011-05-03 20:05:04 UTC (rev 24905)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/ImageCache.as   
    2011-05-03 20:17:37 UTC (rev 24906)
@@ -123,31 +123,31 @@
                 releasePrevious(_styleUrl);
                 var vs:VisualStyleVO = VisualStyleVO(style);
                 
-                   for each (pname in IMG_PROPS) {
-                       if (vs.hasVisualProperty(pname)) {
-                           var vp:VisualPropertyVO = 
vs.getVisualProperty(pname);
-                           // Default value:
-                           url = vp.defaultValue;
-                           loadIfNew(url, _styleUrl);
-                           
-                           // Discrete Mapper values:
-                           var mapper:VizMapperVO= vp.vizMapper;
-                           
-                           if (mapper is DiscreteVizMapperVO) {
-                               var dm:DiscreteVizMapperVO = 
DiscreteVizMapperVO(mapper);
-                               values = dm.distinctValues;
-                               
-                               for each (url in values) {
+                for each (pname in IMG_PROPS) {
+                    if (vs.hasVisualProperty(pname)) {
+                        var vp:VisualPropertyVO = vs.getVisualProperty(pname);
+                        // Default value:
+                        url = vp.defaultValue;
+                        loadIfNew(url, _styleUrl);
+                        
+                        // Discrete Mapper values:
+                        var mapper:VizMapperVO= vp.vizMapper;
+                        
+                        if (mapper is DiscreteVizMapperVO) {
+                            var dm:DiscreteVizMapperVO = 
DiscreteVizMapperVO(mapper);
+                            values = dm.distinctValues;
+                            
+                            for each (url in values) {
                                 loadIfNew(url, _styleUrl);
-                               }
-                           } else if (mapper != null && nodes != null) {
-                               for each (var n:NodeSprite in nodes) {
-                                  url = mapper.getValue(n.data);
-                                  loadIfNew(url, _styleUrl);
-                               }
-                           }
-                       }
-                   }
+                            }
+                        } else if (mapper != null && nodes != null) {
+                            for each (var n:NodeSprite in nodes) {
+                               url = mapper.getValue(n.data);
+                               loadIfNew(url, _styleUrl);
+                            }
+                        }
+                    }
+                }
             } else if (style is VisualStyleBypassVO) {
                 releasePrevious(_bypassUrl);
 
@@ -222,14 +222,14 @@
         }
         
         private function checkOnLoadingEnd():void {
-               if (_onLoadingEnd != null) {
-                       if (!isLoading()) {
-                           // Execute the callback function only once!
+            if (_onLoadingEnd != null) {
+                if (!isLoading()) {
+                    // Execute the callback function only once!
                     var fn:Function = _onLoadingEnd;
                     _onLoadingEnd = null;
                     fn(undefined);
-                       }
-               }
+                }
+            }
         }
         
         private function retain(url:String):void {
@@ -252,6 +252,9 @@
                 if (_imgCounter[url] === 0) {
                     delete _imgCounter[url];
                     delete _broken[url];
+                    
+                    var bd:BitmapData = _images[url];
+                    if (bd != null) bd.dispose();
                     delete _images[url];
                 }
             }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to