patch1 to text.C fixes the DEPM crash. refresh_row was used before being set
(it was 0x0).

I believe that this refresh_row was (ab)used as a method of keeping a valid
Row pointer while calling "row mangling" methods (because it's updated on
removeRow), and possibly John removed the setting of refresh_row in his
update/paint cleaning. In the meantime, this fixes the crash.

patch2 to lyxrow.C. On lastPos we returned 0 if the row's paragraph is void.
But zero is the right value to return if the paragraph has 1 char, so this
is pretty wrong. Moreover, returning 0 fires a bogus getChar request on
computeBidiTables (activate rtl, file->new, crash). I've put it to return
-1 without problems so far.

With these two changes I'm unable to get a crash with current CVS, so it's
pretty usable to me.

PS: patch to changelog on a different file for if someone wants to apply
only 1 of the patches, so remove one entry if appropiate.

Alfredo
Index: ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.1141
diff -u -p -u -r1.1141 ChangeLog
--- ChangeLog	2003/03/21 23:53:25	1.1141
+++ ChangeLog	2003/03/22 11:39:32
@@ -1,3 +1,11 @@
+2003-03-22  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* lyxrow.C (lastPos): return -1 if the row is void
+
+2003-03-22  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* text.C: fix a crash on DEPM
+
 2003-03-21  Alfredo Braunstein  <[EMAIL PROTECTED]>
 
 	* lyxtext.h:
Index: text2.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text2.C,v
retrieving revision 1.297
diff -u -p -u -r1.297 text2.C
--- text2.C	2003/03/20 14:39:23	1.297
+++ text2.C	2003/03/22 11:40:07
@@ -2350,11 +2350,13 @@ bool LyXText::deleteEmptyParagraphMechan
 			 * the parindent that can occur or dissappear.
 			 * The next row can change its height, if
 			 * there is another layout before */
-			if (refresh_row->next()) {
-				breakAgain(refresh_row->next());
-				updateCounters();
+			if (refresh_row) {
+				if (refresh_row->next()) {
+					breakAgain(refresh_row->next());
+					updateCounters();
+				}
+				setHeightOfRow(refresh_row);
 			}
-			setHeightOfRow(refresh_row);
 		} else {
 			Row * nextrow = old_cursor.row()->next();
 			const_cast<LyXText *>(this)->postPaint(
Index: lyxrow.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxrow.C,v
retrieving revision 1.20
diff -u -p -u -r1.20 lyxrow.C
--- lyxrow.C	2003/03/21 14:20:45	1.20
+++ lyxrow.C	2003/03/22 11:36:36
@@ -168,8 +168,12 @@ bool Row::isParEnd() const
 
 pos_type Row::lastPos() const
 {
+	/*We used to return 0 here, don't know why, and this breaks 
+	  computeBidiTables. If no problems are detected, the following
+	  if should be removed. (Ab)
+	 */
 	if (!par()->size())
-		return 0;
+		return -1;
 
 	if (isParEnd()) {
 		return par()->size() - 1;

Reply via email to