Commit 528d6b1b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Elimina bucle infinito al cancelar un Wizard

El problema era causado por _WizardStep, que se encargaba de mandar a su
instancia del modelo la orden de CLEAR al mismo tiempo que escuchaba su
respuesta, para volver a hacer lo mismo. Esto causaba un desbordamiento
de pila que mantenía a la aplicación colgada durante minutos (o
directamente la mataba).
Esta funcionalidad no parece ser necesaria, ni ahora ni en el momento en
que se definió, ya que tanto CLEAR como RESET lanzados desde la botonera
de Wizard parecen responder bien.
En caso de detectar la necesidad de escuchar que el modelo se ha
limpiado o reiniciado desde un paso de Wizard, habrá buscar la manera de
implementarlo correctamente, no de la manera en que se hizo.
parent d3560fbb
Loading
Loading
Loading
Loading
+3 −41
Original line number Diff line number Diff line
@@ -188,9 +188,10 @@ define([

		_setModel: function(res) {

			// TODO revisar esto, puede ser el origen de problema de ciclado al cancelar?? quizá desconectar primero
			if (this.modelInstance)
			if (this.modelInstance) {
				// TODO revisar esto, puede originar problemas, quizá desconectar y/o destruir primero
				delete this.modelInstance;
			}

			res.parentChannel = this.getChannel();

@@ -238,12 +239,6 @@ define([
				options: {
					predicate: lang.hitch(this, this._chkGotIdProperty)
				}
			},{
				channel: this._buildChannel(this.modelChannel, this.actions.CLEAR),
				callback: "_subClearModel"
			},{
				channel: this._buildChannel(this.modelChannel, this.actions.RESET),
				callback: "_subResetModel"
			}]);
		},

@@ -433,7 +428,6 @@ define([

		_evaluateValidationErrors: function(obj) {

			// TODO aquí parece entrar más veces de las necesarias, quizá cause ciclo, revisar
			var errors = obj.errors || {},
				isValidProperty = this._isValidProperty;

@@ -574,38 +568,6 @@ define([
					properties: [this.propertyName]
				});
			}
		},

		_subResetModel: function(res) {

			var properties = res && res.properties;

			if (this.propertyName &&
				(!properties || !properties.length || this._propertyNameInProperties(properties))) {
				this._resetStep();
			}
		},

		_subClearModel: function(res) {

			// TODO aqui se puede ciclar, si el step hace clear y el modelo responde y vuelta a empezar, revisar
			var properties = res && res.properties;

			if (this.propertyName &&
				(!properties || !properties.length || this._propertyNameInProperties(properties))) {
				this._clearStep();
			}
		},

		_propertyNameInProperties: function(properties) {

			for (var i = 0; i < properties.length; i++) {
				if (properties[i] === this.properties) {
					return true;
				}
			}

			return false;
		}
	});
});