Author: fabien
Date: 2012-04-20 20:02:25 -0700 (Fri, 20 Apr 2012)
New Revision: 9362
Log:
STR2731 fixing: potential use of unassigned (Y) value
Modified:
branches/branch-1.3/src/Fl_Text_Display.cxx
Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2012-04-20 10:52:07 UTC (rev
9361)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2012-04-21 03:02:25 UTC (rev
9362)
@@ -803,26 +803,22 @@
\param pos character index
\param[out] X, Y pixel position of character on screen
- \return 0 if character vertically out of view, X position otherwise
+ \return 0 if character vertically out of view, X & Y positions otherwise
*/
int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
IS_UTF8_ALIGNED2(buffer(), pos)
int lineStartPos, fontHeight;
int visLineNum;
-
/* If position is not displayed, return false */
if (pos < mFirstChar || (pos > mLastChar && !empty_vlines())) {
- return 0;
+ return (*X=*Y=0); // make sure X & Y are set when it is out of view
}
/* Calculate Y coordinate */
- if (!position_to_line(pos, &visLineNum)) {
- return 0;
+ if (!position_to_line(pos, &visLineNum) || visLineNum < 0 || visLineNum >
mNBufferLines) {
+ return (*X=*Y=0); // make sure X & Y are set when it is out of view
}
- if (visLineNum < 0 || visLineNum > mNBufferLines) {
- return 0;
- }
fontHeight = mMaxsize;
*Y = text_area.y + visLineNum * fontHeight;
@@ -3469,10 +3465,12 @@
text_area.h);
int X, Y;
- if (position_to_xy(mCursorPos, &X, &Y)) draw_cursor(X, Y);
+ if (position_to_xy(mCursorPos, &X, &Y)) {
+ draw_cursor(X, Y);
+ mCursorOldY = Y;
+ }
// else puts("position_to_xy() failed - unable to draw cursor!");
//printf("drew cursor at pos: %d (%d,%d)\n", mCursorPos, X, Y);
- mCursorOldY = Y;
fl_pop_clip();
}
fl_pop_clip();
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit