From 37b53c6030da5046ef31a2a3fe9bc79087b3bc69 Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Mon, 13 May 2019 17:03:46 +0300 Subject: [PATCH 1/4] fix(text): crash when removing FormattedText (#7237) * fix(text): crash when removing FormattedText * refactor: fixed crash on ios too --- tests/app/ui/label/label-tests.ts | 27 ++++++++++++++----- .../ui/text-base/text-base.android.ts | 4 +-- .../ui/text-base/text-base.ios.ts | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/app/ui/label/label-tests.ts b/tests/app/ui/label/label-tests.ts index 5063e903f..6e4f416af 100644 --- a/tests/app/ui/label/label-tests.ts +++ b/tests/app/ui/label/label-tests.ts @@ -162,10 +162,10 @@ export class LabelTest extends testModule.UITest { const span = new Span(); span.text = "long label"; span.fontWeight = "bold"; - + const span2 = new Span(); span2.text = "long label"; - + const formattedString = new FormattedString(); formattedString.spans.push(span); formattedString.spans.push(span2); @@ -176,7 +176,7 @@ export class LabelTest extends testModule.UITest { const span3 = new Span(); span3.text = "short label"; span3.fontWeight = "bold"; - + const formattedString2 = new FormattedString(); formattedString2.spans.push(span3); label.formattedText = formattedString2; @@ -210,7 +210,7 @@ export class LabelTest extends testModule.UITest { const span = new Span(); span.text = "short label"; span.fontWeight = "bold"; - + const formattedString = new FormattedString(); formattedString.spans.push(span); label.formattedText = formattedString; @@ -220,10 +220,10 @@ export class LabelTest extends testModule.UITest { const span2 = new Span(); span2.text = "long label"; span2.fontWeight = "bold"; - + const span3 = new Span(); span3.text = "long label"; - + const formattedString2 = new FormattedString(); formattedString2.spans.push(span2); formattedString2.spans.push(span3); @@ -733,6 +733,21 @@ export class LabelTest extends testModule.UITest { return host; }); } + + public test_FormattedText_ShouldNotCrash_WheRemovedFromSpan() { + const label = this.testView; + label.color = new colorModule.Color("red"); + this.waitUntilTestElementIsLoaded(); + + const span = new Span(); + span.text = "test"; + + const formattedString = new FormattedString(); + formattedString.spans.push(span); + + label._addChildFromBuilder("FormattedString", formattedString); + label._removeView(formattedString); + }; } export function createTestCase(): LabelTest { diff --git a/tns-core-modules/ui/text-base/text-base.android.ts b/tns-core-modules/ui/text-base/text-base.android.ts index 4dfd0d45f..9ae4eb367 100644 --- a/tns-core-modules/ui/text-base/text-base.android.ts +++ b/tns-core-modules/ui/text-base/text-base.android.ts @@ -12,7 +12,7 @@ import { isString } from "../../utils/types"; export * from "./text-base-common"; interface TextTransformation { - new (owner: TextBase): android.text.method.TransformationMethod; + new(owner: TextBase): android.text.method.TransformationMethod; } let TextTransformation: TextTransformation; @@ -344,7 +344,7 @@ export function getTransformedText(text: string, textTransform: TextTransform): } function createSpannableStringBuilder(formattedString: FormattedString): android.text.SpannableStringBuilder { - if (!formattedString) { + if (!formattedString || !formattedString.parent) { return null; } diff --git a/tns-core-modules/ui/text-base/text-base.ios.ts b/tns-core-modules/ui/text-base/text-base.ios.ts index e9303a108..69c2c1bcf 100644 --- a/tns-core-modules/ui/text-base/text-base.ios.ts +++ b/tns-core-modules/ui/text-base/text-base.ios.ts @@ -231,7 +231,7 @@ export class TextBase extends TextBaseCommon { createNSMutableAttributedString(formattedString: FormattedString): NSMutableAttributedString { let mas = NSMutableAttributedString.alloc().init(); - if (formattedString) { + if (formattedString && formattedString.parent) { for (let i = 0, spanStart = 0, length = formattedString.spans.length; i < length; i++) { const span = formattedString.spans.getItem(i); const text = span.text; From fe9e781c05d6671b6d605a1579ba08941cb650c9 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Sun, 12 May 2019 00:40:13 +0300 Subject: [PATCH 2/4] release: cut the 5.4.0 release --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ tns-core-modules/package.json | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a659ae6..18f6fc71d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ + +# [5.4.0](https://github.com/NativeScript/NativeScript/compare/5.3.2...5.4.0) (2019-05-11) + + +### Bug Fixes + +* throw if failed to load component ([#7186](https://github.com/NativeScript/NativeScript/issues/7186)) ([b7abb3d](https://github.com/NativeScript/NativeScript/commit/b7abb3d)) +* **android/button:** possible incorrect button visual state ([#7190](https://github.com/NativeScript/NativeScript/issues/7190)) ([2a02360](https://github.com/NativeScript/NativeScript/commit/2a02360)) +* **devtools-ios:** Ensure UI modifications run on main thread ([c60f74d](https://github.com/NativeScript/NativeScript/commit/c60f74d)), closes [#7219](https://github.com/NativeScript/NativeScript/issues/7219) +* **ios:** add null check to TouchGestureRecognizer ([#7182](https://github.com/NativeScript/NativeScript/issues/7182)) ([7d3f0d9](https://github.com/NativeScript/NativeScript/commit/7d3f0d9)) +* **ios:** application.displayedEvent does not depend on trace to fire ([#7141](https://github.com/NativeScript/NativeScript/issues/7141)) ([#7156](https://github.com/NativeScript/NativeScript/issues/7156)) ([4e56c89](https://github.com/NativeScript/NativeScript/commit/4e56c89)) +* **iOS:** Image cache module not longer sets null in NSCache ([#7171](https://github.com/NativeScript/NativeScript/issues/7171)) ([4f79d2e](https://github.com/NativeScript/NativeScript/commit/4f79d2e)) +* **ios-modal:** closeCallback not being called with popover presentation style ([#7189](https://github.com/NativeScript/NativeScript/issues/7189)) ([aa44eb9](https://github.com/NativeScript/NativeScript/commit/aa44eb9)) +* **ios-tabview:** crash when setting tab text color ([#7188](https://github.com/NativeScript/NativeScript/issues/7188)) ([77c45da](https://github.com/NativeScript/NativeScript/commit/77c45da)) + + +### Features + +* **android:** elevation shadow support ([#7136](https://github.com/NativeScript/NativeScript/issues/7136)) ([cf533a7](https://github.com/NativeScript/NativeScript/commit/cf533a7)) +* **android:** implement a 'activityNewIntent' event ([3efc06e](https://github.com/NativeScript/NativeScript/commit/3efc06e)) +* **android:** implement BorderDrawable outline ([ec07a99](https://github.com/NativeScript/NativeScript/commit/ec07a99)) +* **hmr:** preserve navigation history on applying changes ([#7146](https://github.com/NativeScript/NativeScript/issues/7146)) ([d35e14e](https://github.com/NativeScript/NativeScript/commit/d35e14e)) +* **switch:** add property for off state background color ([#7138](https://github.com/NativeScript/NativeScript/issues/7138)) ([f0146f0](https://github.com/NativeScript/NativeScript/commit/f0146f0)) + + + ## [5.3.2](https://github.com/NativeScript/NativeScript/compare/5.3.1...5.3.2) (2019-05-03) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index 91a26be78..ca4282a73 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -26,7 +26,7 @@ "license": "Apache-2.0", "typings": "tns-core-modules.d.ts", "dependencies": { - "tns-core-modules-widgets": "next", + "tns-core-modules-widgets": "5.4.0", "tslib": "^1.9.3" }, "devDependencies": { From 8e5676959a6c8fb9a76f51b03f78d391ffa7db9e Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 14 May 2019 11:24:34 +0300 Subject: [PATCH 3/4] chore: update changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18f6fc71d..0537ba975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# [5.4.0](https://github.com/NativeScript/NativeScript/compare/5.3.2...5.4.0) (2019-05-11) +# [5.4.0](https://github.com/NativeScript/NativeScript/compare/5.3.2...5.4.0) (2019-05-14) ### Bug Fixes @@ -9,9 +9,10 @@ * **devtools-ios:** Ensure UI modifications run on main thread ([c60f74d](https://github.com/NativeScript/NativeScript/commit/c60f74d)), closes [#7219](https://github.com/NativeScript/NativeScript/issues/7219) * **ios:** add null check to TouchGestureRecognizer ([#7182](https://github.com/NativeScript/NativeScript/issues/7182)) ([7d3f0d9](https://github.com/NativeScript/NativeScript/commit/7d3f0d9)) * **ios:** application.displayedEvent does not depend on trace to fire ([#7141](https://github.com/NativeScript/NativeScript/issues/7141)) ([#7156](https://github.com/NativeScript/NativeScript/issues/7156)) ([4e56c89](https://github.com/NativeScript/NativeScript/commit/4e56c89)) -* **iOS:** Image cache module not longer sets null in NSCache ([#7171](https://github.com/NativeScript/NativeScript/issues/7171)) ([4f79d2e](https://github.com/NativeScript/NativeScript/commit/4f79d2e)) +* **ios:** image cache module not longer sets null in NSCache ([#7171](https://github.com/NativeScript/NativeScript/issues/7171)) ([4f79d2e](https://github.com/NativeScript/NativeScript/commit/4f79d2e)) * **ios-modal:** closeCallback not being called with popover presentation style ([#7189](https://github.com/NativeScript/NativeScript/issues/7189)) ([aa44eb9](https://github.com/NativeScript/NativeScript/commit/aa44eb9)) * **ios-tabview:** crash when setting tab text color ([#7188](https://github.com/NativeScript/NativeScript/issues/7188)) ([77c45da](https://github.com/NativeScript/NativeScript/commit/77c45da)) +* **text:** crash when removing FormattedText ([#7237](https://github.com/NativeScript/NativeScript/issues/7237)) ([37b53c6](https://github.com/NativeScript/NativeScript/commit/37b53c6)) ### Features From 047dbe344c9f144fcc8e97eb4a118f67362b35d3 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Wed, 15 May 2019 16:10:32 +0300 Subject: [PATCH 4/4] chore: revert widgets dep to next --- tns-core-modules/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index ca4282a73..91a26be78 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -26,7 +26,7 @@ "license": "Apache-2.0", "typings": "tns-core-modules.d.ts", "dependencies": { - "tns-core-modules-widgets": "5.4.0", + "tns-core-modules-widgets": "next", "tslib": "^1.9.3" }, "devDependencies": {