[OpenLayers-Dev] Fwd: [OpenLayers-Commits] r6230 - trunk/openlayers/lib/OpenLayers

Erik Uzureau euzuro at gmail.com
Tue Feb 12 11:51:04 EST 2008


i dont know what the specific case is here, but i know the following
rule tends to work in 99% of cases:

if you create it, you destroy it. if you register it, you unregister it.


---------- Forwarded message ----------
From:  <commits at openlayers.org>
Date: Feb 12, 2008 10:43 AM
Subject: [OpenLayers-Commits] r6230 - trunk/openlayers/lib/OpenLayers
To: commits at openlayers.org


Author: tschaub
Date: 2008-02-12 11:43:47 -0500 (Tue, 12 Feb 2008)
New Revision: 6230

Modified:
  trunk/openlayers/lib/OpenLayers/Control.js
Log:
Only destroy events if they are not already destroyed.  This is
relevant for controls with obligate controls.  Since the map thinks it
is in charge of destroying controls, and parent controls also destroy
obligate controls, control.destroy ends up getting called twice.  If
someone wants to change the way this is handled, we should have a
standard property that lets the map know that control.destroy is the
responsibility of someone else.  r=crschmidt (closes #1346)

Modified: trunk/openlayers/lib/OpenLayers/Control.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control.js  2008-02-12 16:33:23
UTC (rev 6229)
+++ trunk/openlayers/lib/OpenLayers/Control.js  2008-02-12 16:43:47
UTC (rev 6230)
@@ -165,8 +165,10 @@
     * to prevent memory leaks.
     */
    destroy: function () {
-        this.events.destroy();
-        this.events = null;
+        if(this.events) {
+            this.events.destroy();
+            this.events = null;
+        }
        // eliminate circular references
        if (this.handler) {
            this.handler.destroy();

_______________________________________________
Commits mailing list
Commits at openlayers.org
http://openlayers.org/mailman/listinfo/commits



More information about the Dev mailing list