summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2011-02-24 08:43:34 +0000
committerTom Hacohen <tom@stosb.com>2011-02-24 08:43:34 +0000
commit38bf6ec94cfca93deae54a140214b86948d3c71b (patch)
tree91fac7b62332fe96dbb64debd682ea086d7b6d90
parent28ee865391548e42b41c20aeebd98a80997f5f69 (diff)
Evas textblock: Stringshare the style text of each style.
SVN revision: 57295
-rw-r--r--legacy/evas/src/lib/canvas/evas_object_textblock.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c
index 4cb39e6519..29dd0765b9 100644
--- a/legacy/evas/src/lib/canvas/evas_object_textblock.c
+++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c
@@ -394,7 +394,7 @@ struct _Evas_Object_Textblock_Format
394 394
395struct _Evas_Textblock_Style 395struct _Evas_Textblock_Style
396{ 396{
397 char *style_text; 397 const char *style_text;
398 char *default_tag; 398 char *default_tag;
399 Evas_Object_Style_Tag *tags; 399 Evas_Object_Style_Tag *tags;
400 Eina_List *objects; 400 Eina_List *objects;
@@ -520,13 +520,14 @@ static void _evas_textblock_cursors_set_node(Evas_Object_Textblock *o, const Eva
520/* styles */ 520/* styles */
521/** 521/**
522 * @internal 522 * @internal
523 * Clears the textblock style passed. 523 * Clears the textblock style passed except for the style_text which is replaced.
524 * @param ts The ts to be cleared. Must not be NULL. 524 * @param ts The ts to be cleared. Must not be NULL.
525 * @param style_text the style's text.
525 */ 526 */
526static void 527static void
527_style_clear(Evas_Textblock_Style *ts) 528_style_replace(Evas_Textblock_Style *ts, const char *style_text)
528{ 529{
529 if (ts->style_text) free(ts->style_text); 530 eina_stringshare_replace(&ts->style_text, style_text);
530 if (ts->default_tag) free(ts->default_tag); 531 if (ts->default_tag) free(ts->default_tag);
531 while (ts->tags) 532 while (ts->tags)
532 { 533 {
@@ -538,13 +539,23 @@ _style_clear(Evas_Textblock_Style *ts)
538 free(tag->replace); 539 free(tag->replace);
539 free(tag); 540 free(tag);
540 } 541 }
541 ts->style_text = NULL;
542 ts->default_tag = NULL; 542 ts->default_tag = NULL;
543 ts->tags = NULL; 543 ts->tags = NULL;
544} 544}
545 545
546/** 546/**
547 * @internal 547 * @internal
548 * Clears the textblock style passed.
549 * @param ts The ts to be cleared. Must not be NULL.
550 */
551static void
552_style_clear(Evas_Textblock_Style *ts)
553{
554 _style_replace(ts, NULL);
555}
556
557/**
558 * @internal
548 * Searches inside the tags stored in the style for the tag who's 559 * Searches inside the tags stored in the style for the tag who's
549 * replacement is s of size replace_len; 560 * replacement is s of size replace_len;
550 * @param ts The ts to be cleared. Must not be NULL. 561 * @param ts The ts to be cleared. Must not be NULL.
@@ -3900,14 +3911,13 @@ evas_textblock_style_set(Evas_Textblock_Style *ts, const char *text)
3900 _evas_textblock_text_node_changed(o, obj, NULL); 3911 _evas_textblock_text_node_changed(o, obj, NULL);
3901 } 3912 }
3902 3913
3903 _style_clear(ts); 3914 _style_replace(ts, text);
3904 if (text) ts->style_text = strdup(text);
3905 3915
3906 if (ts->style_text) 3916 if (ts->style_text)
3907 { 3917 {
3908 // format MUST be KEY='VALUE'[KEY='VALUE']... 3918 // format MUST be KEY='VALUE'[KEY='VALUE']...
3909 char *p; 3919 const char *p;
3910 char *key_start, *key_stop, *val_start, *val_stop; 3920 const char *key_start, *key_stop, *val_start, *val_stop;
3911 3921
3912 key_start = key_stop = val_start = val_stop = NULL; 3922 key_start = key_stop = val_start = val_stop = NULL;
3913 p = ts->style_text; 3923 p = ts->style_text;