STR2731 fixing: potential use of unassigned (Y) value
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9362 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
526efe8a13
commit
226f425443
@ -803,25 +803,21 @@ void Fl_Text_Display::overstrike(const char* text) {
|
||||
|
||||
\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 (visLineNum < 0 || visLineNum > mNBufferLines) {
|
||||
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
|
||||
}
|
||||
|
||||
fontHeight = mMaxsize;
|
||||
@ -3469,10 +3465,12 @@ void Fl_Text_Display::draw(void) {
|
||||
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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user