Taking AW through a test run using Purify, I'm sad to report that there are
again more than a few places where uninitialized class data is read.
This invokes "undefined behaviour", which in theory means it is allowed to
do anything.
Perhaps the worst example I've seen now is a call inside
EV_Win32Toolbar::synthesize where the code uses a member
"m_pWin32ToolbarIcons". This member is *never* initialized. In fact, it
pointed south.
Until I check in to this more, here are some replacement constructors for
the first five classes Purify complained about. As for the
m_pWin32ToolbarIcons I don't know what to do just yet (meaning I haven't yet
looked into it). Sorry for not supplying patches, but they are at least
simple drop-in replacements fro existing constructors.
/Mike - please don't cc
AP_StatusBar::AP_StatusBar(XAP_Frame * pFrame)
: m_pFrame(pFrame),
m_pView(0),
m_pG(0),
m_iHeight(0),
m_iWidth(0),
s_iFixedHeight(20),
m_bInitFields(UT_FALSE),
m_pStatusMessageField(0)
{
const XML_Char * szRulerUnits;
if (pFrame->getApp()->getPrefsValue(AP_PREF_KEY_RulerUnits,&szRulerUnits))
m_dim = UT_determineDimension(szRulerUnits);
else
m_dim = DIM_IN;
// really this should be "static const x = 20;" in the
// class declaration, but MSVC5 can't handle it....
// (GCC can :-)
s_iFixedHeight = 20;
m_bufUCS[0] = 0;
}
FV_View::FV_View(XAP_App * pApp, void* pParentData, FL_DocLayout* pLayout)
: AV_View(pApp, pParentData),
m_iInsPoint(0),
m_xPoint(0),
m_yPoint(0),
m_iPointHeight(0),
m_oldxPoint(0),
m_oldyPoint(0),
m_oldiPointHeight(0),
m_xPointSticky(0),
m_bPointVisible(UT_FALSE),
m_bPointEOL(UT_FALSE),
m_bDontChangeInsPoint(UT_FALSE),
m_pLayout(pLayout),
m_pDoc(pLayout->getDocument()),
m_pG(m_pLayout->getGraphics()),
m_pParentData(pParentData),
m_iSelectionAnchor(0),
m_iSelectionLeftAnchor(0),
m_iSelectionRightAnchor(0),
m_bSelection(UT_FALSE),
m_pAutoScrollTimer(0),
m_xLastMouse(0),
m_yLastMouse(0),
m_pAutoCursorTimer(0),
m_bCursorIsOn(UT_FALSE),
m_bEraseSaysStopBlinking(UT_FALSE),
m_bdontSpellCheckRightNow(UT_FALSE),
m_wrappedEnd(UT_FALSE),
m_startPosition(0),
m_doneFind(UT_FALSE),
_m_matchCase(UT_FALSE),
_m_findNextString(0),
m_bShowPara(UT_FALSE)
{
// UT_ASSERT(m_pG->queryProperties(GR_Graphics::DGP_SCREEN));
// initialize prefs cache
pApp->getPrefsValueBool(AP_PREF_KEY_CursorBlink, &m_bCursorBlink);
// initialize prefs listener
pApp->getPrefs()->addListener( _prefsListener, this );
// initialize change cache
m_chg.bUndo = UT_FALSE;
m_chg.bRedo = UT_FALSE;
m_chg.bDirty = UT_FALSE;
m_chg.bSelection = UT_FALSE;
m_chg.iColumn = 0; // current column number
m_chg.propsChar = NULL;
m_chg.propsBlock = NULL;
m_chg.propsSection = NULL;
pLayout->setView(this);
pLayout->formatAll();
//Test_Dump();
moveInsPtTo(FV_DOCPOS_BOD);
m_iSelectionAnchor = getPoint();
_resetSelection();
_clearOldPoint();
_fixInsertionPointCoords();
}
XAP_Frame::XAP_Frame(XAP_App * app)
: m_app(app),
m_pDoc(0),
m_pView(0),
m_pViewListener(0),
m_lid((AV_ListenerId)-1),
m_pScrollObj(0),
m_szMenuLayoutName(0),
m_szMenuLabelSetName(0),
m_szToolbarLabelSetName(0),
m_szToolbarAppearance(0),
m_nView(0),
m_iUntitled(0),
m_pMouse(0),
m_pKeyboard(0),
m_pScrollbarViewListener(0),
m_lidScrollbarViewListener((AV_ListenerId)-1),
m_zoomType(z_100),
m_pData(0),
m_pInputModes(0)
{
m_app->rememberFrame(this);
memset(m_szTitle,0,sizeof(m_szTitle));
memset(m_szNonDecoratedTitle,0,sizeof(m_szNonDecoratedTitle));
}
XAP_Frame::XAP_Frame(XAP_Frame * f)
: m_app(f->m_app), // only clone a few things
m_pDoc(REFP(f->m_pDoc)),
m_pView(0),
m_pViewListener(0),
m_lid((AV_ListenerId)-1),
m_pScrollObj(0),
m_szMenuLayoutName(0),
m_szMenuLabelSetName(0),
m_szToolbarLabelSetName(0),
m_szToolbarAppearance(0),
m_nView(0),
m_iUntitled(f->m_iUntitled),
m_pMouse(0),
m_pKeyboard(0),
m_pScrollbarViewListener(0),
m_lidScrollbarViewListener((AV_ListenerId)-1),
m_zoomType(z_100),
m_pData(0),
m_pInputModes(0)
{
m_app->rememberFrame(this, f);
memset(m_szTitle,0,sizeof(m_szTitle));
memset(m_szNonDecoratedTitle,0,sizeof(m_szNonDecoratedTitle));
}
XAP_Win32Frame::XAP_Win32Frame(XAP_Win32App * app)
: XAP_Frame(app),
m_pWin32App(app),
m_pWin32Menu(0),
m_pWin32Popup(0),
m_iBarHeight(0),
m_iStatusBarHeight(0),
m_hwndFrame(0),
m_hwndRebar(0),
m_hwndContainer(0),
m_hwndStatusBar(0),
m_dialogFactory(this, app),
m_mouseWheelMessage(0),
m_iSizeWidth(0),
m_iSizeHeight(0)
{
}
// TODO when cloning a new frame from an existing one
// TODO should we also clone any frame-persistent
// TODO dialog data ??
XAP_Win32Frame::XAP_Win32Frame(XAP_Win32Frame * f)
: XAP_Frame(f),
m_pWin32App(f->m_pWin32App),
m_pWin32Menu(0),
m_pWin32Popup(0),
m_iBarHeight(0),
m_iStatusBarHeight(0),
m_hwndFrame(0),
m_hwndRebar(0),
m_hwndContainer(0),
m_hwndStatusBar(0),
m_dialogFactory(this, f->m_pWin32App),
m_mouseWheelMessage(0),
m_iSizeWidth(0),
m_iSizeHeight(0)
{
}
fp_Container::fp_Container(UT_uint32 iType, fl_SectionLayout* pSectionLayout)
: m_iType(iType),
m_pPage(0),
m_iWidth(0),
m_iWidthLayoutUnits(0),
m_iHeight(0),
m_iMaxHeight(0),
m_iHeightLayoutUnits(0),
m_iMaxHeightLayoutUnits(0),
m_iX(0),
m_iY(0),
m_pSectionLayout(pSectionLayout)
{
UT_ASSERT(pSectionLayout);
m_pG = m_pSectionLayout->getDocLayout()->getGraphics();
}