Fixes issued raised in STR #3422; Fl_Text_Display constructor order issues;

organize member initialization first, method calls last.

Also: 
    Reorg'ed member initialization to match order in .H
    to detect missing member inits.

    Noticed member mModifyingTabDistance is unused.
    Tagged with XXX: but left in place, since it's
    a protected member, and might be utilized by user code.
    We should probably remove this member.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12570 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano 2017-11-23 19:34:33 +00:00
parent 02d58597e9
commit 0fb2a55fc8
2 changed files with 69 additions and 62 deletions

View File

@ -558,9 +558,8 @@ protected:
int mNLinesDeleted; /* Number of lines deleted during
buffer modification (only used
when resynchronization is suppressed) */
int mModifyingTabDistance; /* Whether tab distance is being
modified */
int mModifyingTabDistance; /* Whether tab distance is being modified XXX: UNUSED */
mutable double mColumnScale; /* Width in pixels of an average character. This
value is calculated as needed (lazy eval); it
needs to be mutable so that it can be calculated

View File

@ -97,82 +97,90 @@ static int scroll_x = 0;
*/
Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
: Fl_Group(X, Y, W, H, l) {
int i;
mMaxsize = 0;
// Member initialization: same order as declared in .H file
// Any Fl_Text_Display methods should only be called /after/ all
// members initialized; avoids methods referencing uninitialized values.
//
damage_range1_start = damage_range1_end = -1;
damage_range2_start = damage_range2_end = -1;
dragPos = dragging = 0;
dragType = DRAG_CHAR;
display_insert_position_hint = 0;
shortcut_ = 0;
mCursorPos = 0;
mCursorOn = 0;
mCursorOldY = -100;
mCursorToHint = NO_HINT;
mCursorStyle = NORMAL_CURSOR;
mCursorPreferredXPos = -1;
mNVisibleLines = 1;
mNBufferLines = 0;
mBuffer = NULL;
mStyleBuffer = NULL;
mFirstChar = 0;
mLastChar = 0;
mContinuousWrap = 0;
mWrapMarginPix = 0;
mLineStarts = new int[mNVisibleLines];
{ // This code unused unless mNVisibleLines is ever initialized >1
for (int i=1; i<mNVisibleLines; i++) mLineStarts[i] = -1;
}
mLineStarts[0] = 0;
mTopLineNum = 1;
mAbsTopLineNum = 1;
mNeedAbsTopLineNum = 0;
mHorizOffset = 0;
mTopLineNumHint = 1;
mHorizOffsetHint = 0;
mNStyles = 0;
mStyleTable = NULL;
mUnfinishedStyle = 0;
mUnfinishedHighlightCB = 0;
mHighlightCBArg = 0;
mMaxsize = 0;
mSuppressResync = 0;
mNLinesDeleted = 0;
mModifyingTabDistance = 0; // XXX: UNUSED
mColumnScale = 0;
mCursor_color = FL_FOREGROUND_COLOR;
color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
box(FL_DOWN_FRAME);
textsize(FL_NORMAL_SIZE);
textcolor(FL_FOREGROUND_COLOR);
textfont(FL_HELVETICA);
set_flag(SHORTCUT_LABEL);
mHScrollBar = new Fl_Scrollbar(0,0,1,1);
mHScrollBar->callback((Fl_Callback*)h_scrollbar_cb, this);
mHScrollBar->type(FL_HORIZONTAL);
mVScrollBar = new Fl_Scrollbar(0,0,1,1);
mVScrollBar->callback((Fl_Callback*)v_scrollbar_cb, this);
scrollbar_width_ = 0; // 0: default from Fl::scrollbar_size()
scrollbar_align_ = FL_ALIGN_BOTTOM_RIGHT;
dragPos = 0;
dragType = DRAG_CHAR;
dragging = 0;
display_insert_position_hint = 0;
text_area.x = 0;
text_area.y = 0;
text_area.w = 0;
text_area.h = 0;
mVScrollBar = new Fl_Scrollbar(0,0,1,1);
mVScrollBar->callback((Fl_Callback*)v_scrollbar_cb, this);
mHScrollBar = new Fl_Scrollbar(0,0,1,1);
mHScrollBar->callback((Fl_Callback*)h_scrollbar_cb, this);
mHScrollBar->type(FL_HORIZONTAL);
shortcut_ = 0;
textfont_ = FL_HELVETICA; // textfont()
textsize_ = FL_NORMAL_SIZE; // textsize()
textcolor_ = FL_FOREGROUND_COLOR; // textcolor()
mLineNumLeft = 0;
mLineNumWidth = 0;
end();
scrollbar_width_ = 0; // 0: uses Fl::scrollbar_size()
scrollbar_align_ = FL_ALIGN_BOTTOM_RIGHT;
mCursorOn = 0;
mCursorPos = 0;
mCursorOldY = -100;
mCursorToHint = NO_HINT;
mCursorStyle = NORMAL_CURSOR;
mCursorPreferredXPos = -1;
mBuffer = 0;
mFirstChar = 0;
mLastChar = 0;
mNBufferLines = 0;
mTopLineNum = mTopLineNumHint = 1;
mAbsTopLineNum = 1;
mNeedAbsTopLineNum = 0;
mHorizOffset = mHorizOffsetHint = 0;
mCursor_color = FL_FOREGROUND_COLOR;
mStyleBuffer = 0;
mStyleTable = 0;
mNStyles = 0;
mNVisibleLines = 1;
mLineStarts = new int[mNVisibleLines];
mLineStarts[0] = 0;
for (i=1; i<mNVisibleLines; i++)
mLineStarts[i] = -1;
mSuppressResync = 0;
mNLinesDeleted = 0;
mModifyingTabDistance = 0;
mUnfinishedStyle = 0;
mUnfinishedHighlightCB = 0;
mHighlightCBArg = 0;
mLineNumLeft = mLineNumWidth = 0;
mContinuousWrap = 0;
mWrapMarginPix = 0;
mSuppressResync = mNLinesDeleted = mModifyingTabDistance = 0;
linenumber_font_ = FL_HELVETICA;
linenumber_size_ = FL_NORMAL_SIZE;
linenumber_fgcolor_ = FL_INACTIVE_COLOR;
linenumber_bgcolor_ = 53; // ~90% gray
linenumber_align_ = FL_ALIGN_RIGHT;
linenumber_format_ = strdup("%d");
// Method calls -- only AFTER all members initialized
color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
box(FL_DOWN_FRAME);
set_flag(SHORTCUT_LABEL);
end();
}