From 4bd3a948737fd2347ec70904c19024e636a39fcc Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Tue, 25 Jul 2017 10:28:09 +0300 Subject: [PATCH] fix(animations): check if target is present before removing its animation (#4586) In Angular, if the NativeScriptAnimationModule is imported in another NgModule more than once (which shouldn't be done), the renderer is instantiated twice. This causes animation with empty targets to be created. If such animation is removed, the app will crash. Additional check if the target is present will prevent this. --- tns-core-modules/ui/animation/animation.android.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/ui/animation/animation.android.ts b/tns-core-modules/ui/animation/animation.android.ts index 5ae571260..799dd4c6d 100644 --- a/tns-core-modules/ui/animation/animation.android.ts +++ b/tns-core-modules/ui/animation/animation.android.ts @@ -192,14 +192,20 @@ export class Animation extends AnimationBase { this._propertyUpdateCallbacks.forEach(v => v()); this._disableHardwareAcceleration(); this._resolveAnimationFinishedPromise(); - this._target._removeAnimation(this); + + if (this._target) { + this._target._removeAnimation(this); + } } private _onAndroidAnimationCancel() { // tslint:disable-line this._propertyResetCallbacks.forEach(v => v()); this._disableHardwareAcceleration(); this._rejectAnimationFinishedPromise(); - this._target._removeAnimation(this); + + if (this._target) { + this._target._removeAnimation(this); + } } private _createAnimators(propertyAnimation: PropertyAnimation): void { @@ -482,4 +488,4 @@ export class Animation extends AnimationBase { } } } -} \ No newline at end of file +}