Adam Shaw 8 лет назад
Родитель
Сommit
a6a3a2bde3
2 измененных файлов с 19 добавлено и 0 удалено
  1. 1 0
      src/Calendar.render.js
  2. 18 0
      src/common/RenderQueue.js

+ 1 - 0
src/Calendar.render.js

@@ -94,6 +94,7 @@ Calendar.mixin({
 
 
 	destroy: function() {
+		this.renderQueue.kill();
 
 		if (this.view) {
 			this.view.removeElement();

+ 18 - 0
src/common/RenderQueue.js

@@ -4,6 +4,7 @@ var RenderQueue = TaskQueue.extend({
 	waitsByNamespace: null,
 	waitNamespace: null,
 	waitId: null,
+	isKilled: false, // prevents any new tasks from being added
 
 
 	constructor: function(waitsByNamespace) {
@@ -14,6 +15,11 @@ var RenderQueue = TaskQueue.extend({
 
 
 	queue: function(namespace, type, taskFunc) {
+
+		if (this.isKilled) {
+			return;
+		}
+
 		var task = {
 			func: taskFunc,
 			namespace: namespace,
@@ -47,6 +53,18 @@ var RenderQueue = TaskQueue.extend({
 	},
 
 
+	/*
+	Prevents any new tasks from being added AND clears all tasks related to rendering *new* things,
+	however, keeps destroy-related tasks to allow proper cleanup.
+	*/
+	kill: function() {
+		this.isKilled = true;
+		this.q = this.q.filter(function(task) {
+			return task.type === 'destroy-trigger' || task.type === 'destroy';
+		});
+	},
+
+
 	startWait: function(namespace, waitMs) {
 		this.waitNamespace = namespace;
 		this.spawnWait(waitMs);