diff --git a/src/app/app.js b/src/app/app.js index 41905a92955..973765c4f52 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -136,9 +136,12 @@ function (angular, $, _, appLevelRequire) { var $scope = this; $scope.requireContext(deps, function () { var deps = _.toArray(arguments); - $scope.$apply(function () { - fn.apply($scope, deps); - }); + // Check that this is a valid scope. + if($scope.$id) { + $scope.$apply(function () { + fn.apply($scope, deps); + }); + } }); }; }]); diff --git a/src/app/directives/addPanel.js b/src/app/directives/addPanel.js index 2887a54a35e..4d7dee74901 100644 --- a/src/app/directives/addPanel.js +++ b/src/app/directives/addPanel.js @@ -12,6 +12,11 @@ function (angular, app, _) { return { restrict: 'A', link: function($scope, elem) { + + $scope.$on("$destroy",function() { + elem.remove(); + }); + $scope.$watch('panel.type', function() { var _type = $scope.panel.type; $scope.reset_panel(_type); diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index e7a9ddbdc84..505eaa6c7d0 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -13,7 +13,6 @@ function (angular) { '
' + - '' + ''+ ''+ @@ -61,16 +60,22 @@ function (angular) { link: function($scope, elem, attr) { // once we have the template, scan it for controllers and // load the module.js if we have any + var newScope = $scope.$new(); // compile the module and uncloack. We're done function loadModule($module) { $module.appendTo(elem); elem.wrap(container); /* jshint indent:false */ - $compile(elem.contents())($scope); + $compile(elem.contents())(newScope); elem.removeClass("ng-cloak"); } + newScope.$on('$destroy',function(){ + elem.unbind(); + elem.remove(); + }); + $scope.$watch(attr.type, function (name) { elem.addClass("ng-cloak"); // load the panels module file, then render it in the dom. diff --git a/src/app/panels/histogram/module.js b/src/app/panels/histogram/module.js index 734550e1064..94a47e870b3 100644 --- a/src/app/panels/histogram/module.js +++ b/src/app/panels/histogram/module.js @@ -528,7 +528,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { restrict: 'A', template: '
', link: function(scope, elem) { - var data; + var data, plot; scope.$on('refresh',function(){ scope.get_data(); @@ -700,7 +700,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { data[i].data = _d; } - scope.plot = $.plot(elem, data, options); + plot = $.plot(elem, data, options); } catch(e) { // Nothing to do here diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index 768a3cbac62..4731d0bb928 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -134,6 +134,9 @@ function (angular, $, kbn, _, config, moment, Modernizr) { // here before telling the panels to refresh this.refresh = function() { if(self.current.index.interval !== 'none') { + if(_.isUndefined(filterSrv)) { + return; + } if(filterSrv.idsByType('time').length > 0) { var _range = filterSrv.timeRange('last'); kbnIndex.indices(_range.from,_range.to, diff --git a/src/vendor/angular/angular.js b/src/vendor/angular/angular.js index d2115fe1d80..85d0cdca93a 100644 --- a/src/vendor/angular/angular.js +++ b/src/vendor/angular/angular.js @@ -8464,6 +8464,21 @@ function $RootScopeProvider(){ } else { this.$$childHead = this.$$childTail = child; } + + // RASHID: Fix for chrome GC bug + child.$on('$destroy', function() { + if(Child) + Child.prototype = null; + // Async so that the $broadcast('$destroy') can traverse the rest + setTimeout(function() { + child.__proto__ = {}; + for(var i in child) + child[i] = null; + child = null; + return null; + }); + }); + return child; }, @@ -8893,6 +8908,8 @@ function $RootScopeProvider(){ // see: https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = this.$$childTail = null; + parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = + this.$$childTail = null; }, /** diff --git a/src/vendor/jquery/jquery.flot.js b/src/vendor/jquery/jquery.flot.js index fddbdc32ab7..5505c76d113 100644 --- a/src/vendor/jquery/jquery.flot.js +++ b/src/vendor/jquery/jquery.flot.js @@ -2438,9 +2438,9 @@ Licensed under the MIT license. radius = series.points.radius, symbol = series.points.symbol; - // If the user sets the line width to 0, we change it to a very + // If the user sets the line width to 0, we change it to a very // small value. A line width of 0 seems to force the default of 1. - // Doing the conditional here allows the shadow setting to still be + // Doing the conditional here allows the shadow setting to still be // optional even with a lineWidth of 0. if( lw == 0 )