Angus Leeming wrote:

> MSVC complains about line 797 of rowpainter.C:
>     if (vi.p2 < text->paragraphs().size() - 1) {
> 
> \lyx\lyx-devel\src\rowpainter.C(797) : warning C4018: '<' :
> signed/unsigned mismatch
> 
> vi.p2 has type lyx::pit_type (ptrdiff_t).
> text->paragraphs().size() has type std::size_t
> 
> Given that (text->paragraphs().size() == 0) is not unreasonable (I don't
> know if it can happen ever, but that's a secondary issue), I think that
> the correct code should be:
>     if (vi.p2 < lyx::pit_type(text->paragraphs().size()) - 1) {
> 
> Agree?

Silence? Anyway, here's the patch. I'll commit this as it seems to me to
squash a genuine bug.

-- 
Angus
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2122
diff -u -p -r1.2122 ChangeLog
--- src/ChangeLog	15 Feb 2005 13:45:37 -0000	1.2122
+++ src/ChangeLog	15 Feb 2005 19:18:56 -0000
@@ -1,5 +1,10 @@
 2005-02-15  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* rowpainter.C (paintText): Ensure that "paragraphs().size() - 1"
+	can be used meaningfully in a comparison.
+
+2005-02-15  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* lyx_main.C (error_handler):
 	* lyxfunc.C:
 	* lyxrc.C (setDefaults):
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.141
diff -u -p -r1.141 rowpainter.C
--- src/rowpainter.C	31 Jan 2005 16:29:40 -0000	1.141
+++ src/rowpainter.C	15 Feb 2005 19:18:57 -0000
@@ -794,7 +794,7 @@ void paintText(BufferView const & bv, Vi
 			 vi.y1 -  text->getPar(vi.p1 - 1).descent());
 	}
 
-	if (vi.p2 < text->paragraphs().size() - 1) {
+	if (vi.p2 < lyx::pit_type(text->paragraphs().size()) - 1) {
 		text->redoParagraph(vi.p2 + 1);
 		paintPar(pi, *bv.text(), vi.p2 + 1, 0,
 			 vi.y2 + text->getPar(vi.p2 + 1).ascent());

Reply via email to