Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

$destroy() not called at removing marker popup with directive (fixed, code inside) #240

@vincent-ollivier-everysens

Description

Hi there !

If you use an angularjs directive as a marker popup, when the marker is remove from path the $destroy() method is not call. It's a big problem when you deal with popups that use two way binding or watchers, because they continue to live after the marker death ! This is a conceptual bug, who can potentially inflate memory and/or CPU.

I've done a jsfiddle with a corrected version of ui-leaflet.js who send a $destroy()on the $scope of popup directive. The directive finally receive the $destroy event and can do garbage stuff.
Sorry if the fiddle is a little bit crowded, but I had to past all the ui-leaflet code in the javascript section. Just look at the very last lines, they describe a little angular app.

The way it works => jsFiddle :

  1. First ADD a marker with button. This will create marker with directive popup and a $new() scope.
  2. Then launch the popup by clicking on the marker. This will start a timer, have a look to theconsole.
  3. At least REMOVE the marker with button. This will remove it from path and trigger the$destroy event and let a chance to the directive to stop the timer and also, deeper inside Angular, kill the watchers for two way binding.

What I've done to correct it :

At the end of _deleteMarker : markerData.getMessageScope().$destroy();

diff

Can we rapidly mastering this evolution ? Pull request ?

Vincent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions