From: Eunki Hong Date: Thu, 7 Dec 2023 16:59:37 +0000 (+0900) Subject: [NUI] Skip text getter when Text never setted before X-Git-Tag: accepted/tizen/8.0/unified/20240613.065534~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=2b2dddb521daf89061b1457fcd5d94a2425c6631;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Skip text getter when Text never setted before If we never set text into TextLabel before, the result of Text propert getter is always empty. To avoid useless C# - native network, let we just ignore text getter function if we can assume that previous text was empty. Signed-off-by: Eunki Hong --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 058e212..c8f29cc 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -100,6 +100,9 @@ namespace Tizen.NUI.BaseComponents private TextLabelSelectorData selectorData; private string fontFamily = defaultFontFamily; private float fontSizeScale = 1.0f; + + private bool textIsEmpty = true; + private bool hasSystemLanguageChanged = false; private bool hasSystemFontSizeChanged = false; private bool hasSystemFontTypeChanged = false; @@ -141,6 +144,7 @@ namespace Tizen.NUI.BaseComponents public TextLabel(string text) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + textIsEmpty = string.IsNullOrEmpty(text); } /// @@ -153,6 +157,7 @@ namespace Tizen.NUI.BaseComponents public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + textIsEmpty = string.IsNullOrEmpty(text); SetVisible(shown); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs index abb797d..a7bb560 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs @@ -71,7 +71,8 @@ namespace Tizen.NUI.BaseComponents { var textLabel = (TextLabel)bindable; - return Object.InternalGetPropertyString(textLabel.SwigCPtr, TextLabel.Property.TEXT); + // Do not try to get string if we know that previous text was empty. + return textLabel.textIsEmpty ? "" : Object.InternalGetPropertyString(textLabel.SwigCPtr, TextLabel.Property.TEXT); })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -898,6 +899,7 @@ namespace Tizen.NUI.BaseComponents { if (value != null) { + textIsEmpty = string.IsNullOrEmpty(value); Object.InternalSetPropertyString(SwigCPtr, TextLabel.Property.TEXT, value); RequestLayout();