Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        etox.c etox_line.c etox_selection.c 


Log Message:

fix crash when appending text with enlines in it.

update selections when bits change lines.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -3 -r1.59 -r1.60
--- etox.c      20 Aug 2003 17:37:10 -0000      1.59
+++ etox.c      21 Aug 2003 02:03:08 -0000      1.60
@@ -186,9 +186,15 @@
 
        /*
         * Break the incoming text into lines, and merge the first line of the
-        * new text with the last line of the old text.
+        * new text with the last line of the old text. Duplicate text to avoid
+        * read-only memory segv's when parsing.
         */
-       lines = _etox_break_text(et, text);
+       if (text && *text) {
+               text = strdup(text);
+               lines = _etox_break_text(et, text);
+               FREE(text);
+       }
+
        if (!lines)
                return;
 
@@ -262,9 +268,15 @@
 
        /*
         * Break the incoming text into lines, and merge the first line of the
-        * new text with the last line of the old text.
+        * new text with the last line of the old text. Duplicate text to avoid
+        * read-only memory segv's when parsing.
         */
-       lines = _etox_break_text(et, text);
+       if (text && *text) {
+               text = strdup(text);
+               lines = _etox_break_text(et, text);
+               FREE(text);
+       }
+
        if (!lines)
                return;
 
@@ -352,9 +364,15 @@
 
        /*
         * Break the incoming text into lines, and merge the first line of the
-        * new text with the last line of the old text.
+        * new text with the last line of the old text. Duplicate text to avoid
+        * read-only memory segv's when parsing.
         */
-       lines = _etox_break_text(et, text);
+       if (text && *text) {
+               text = strdup(text);
+               lines = _etox_break_text(et, text);
+               FREE(text);
+       }
+
        if (!lines)
                return;
 
@@ -711,7 +729,7 @@
 
        if (index > et->length) {
                sum = et->length;
-                line = evas_list_last(et->lines);
+                line = evas_list_data(evas_list_last(et->lines));
 
                if (h) *h = line->h;
                if (w) *w = line->w / line->length;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- etox_line.c 19 Aug 2003 18:08:12 -0000      1.26
+++ etox_line.c 21 Aug 2003 02:03:08 -0000      1.27
@@ -118,6 +118,8 @@
        if (h > line->h)
                line->h = h;
        line->length += estyle_length(bit);
+
+        etox_selections_update(bit, line);
 }
 
 /*
@@ -143,6 +145,8 @@
 
        line->w += w;
        line->length += estyle_length(bit);
+
+        etox_selections_update(bit, line);
 }
 
 /*
@@ -300,6 +304,8 @@
                bit = line2->bits->data;
                line1->bits = evas_list_append(line1->bits, bit);
                line2->bits = evas_list_remove(line2->bits, bit);
+
+               etox_selections_update(bit, line1);
        }
        /*
         * Adjust the height, width and length of the merged line.
@@ -398,7 +404,7 @@
                                NULL, NULL, NULL, NULL);
 
        /* if we have an index and there is more than one char on the line */
-        if (index != -1){
+       if (index != -1){
                char *tmp;
 
                /* don't start a new line with a space */
@@ -676,8 +682,8 @@
       }
       estyle_set_text(bit, context->marker.text);
       estyle_set_style(bit, context->marker.style);
-      estyle_set_color(bit, context->marker.r, context->marker.g,
-                       context->marker.b, context->marker.a);
+      evas_object_color_set(bit, context->marker.r, context->marker.g,
+                           context->marker.b, context->marker.a);
     }
     else
     {
@@ -690,3 +696,4 @@
       break;
   }
 }
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_selection.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- etox_selection.c    20 Aug 2003 03:25:40 -0000      1.10
+++ etox_selection.c    21 Aug 2003 02:03:08 -0000      1.11
@@ -418,21 +418,38 @@
     {
       line = l->data;
 
-      if (line == selected->start.line)
-      {
-        etox_line_apply_context(line, context, selected->start.bit, NULL);
-      }
-      else if (line == selected->end.line)
-      {
-        etox_line_apply_context(line, context, NULL, selected->end.bit);
+      /*
+       * if start.bit is not on line, then the first bit of line will be
+       * used as the starting bit. same for end.bit.
+       */
+      etox_line_apply_context(line, context, selected->start.bit,
+                              selected->end.bit);
+      
+      if (line == selected->end.line)
         break;
-      }
-      else
-      {
-        etox_line_apply_context(line, context, NULL, NULL);
-      }
     }
   }
   
   etox_layout(selected->etox);
+}
+
+void
+etox_selections_update(Evas_Object *bit, Etox_Line *line)
+{
+       Evas_List *l;
+
+       for (l = active_selections; l; l = l->next)
+       {
+               Etox_Selection *selected = evas_list_data(l);
+               
+               if (selected->start.bit == bit)
+               {
+                 selected->start.line = line;
+               }
+
+               if (selected->end.bit == bit)
+               {
+                 selected->end.line = line;
+               }
+       }
 }




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to