I am writing some tests for someone else's code. I saw a problem with part of the code so I wanted to write a test that would demonstrate the problem. But my testing isn't giving the results that I expected.
This code has a modeless dialog that is created with a 'new' + 'Create', and then when the dialog is dismissed, it calls 'delete this' on itself. But the code author calls the 'new' on a member variable of the mainframe, and doesn't make sure that the modeless dialog is not already showing before calling 'new' on it again. So if the function that shows the dialog is called while the dialog is already showing, then 'new' is performed on a pointer that already points to valid CDialog memory. It would essentially be the same as doing this: CMyDialog* pMyDlg = new CMyDialog; pMyDlg->Create(IDD_MY_DIALOG, this); pMyDlg->ShowWindow(SW_SHOWNORMAL); pMyDlg = new CMyDialog; pMyDlg->Create(IDD_MY_DIALOG, this); pMyDlg->ShowWindow(SW_SHOWNORMAL); pMyDlg = new CMyDialog; pMyDlg->Create(IDD_MY_DIALOG, this); pMyDlg->ShowWindow(SW_SHOWNORMAL); In my testing I tried to create the dialog several times in a row, without dismissing any of the dialogs, then dismiss them and create them in an intermixed order, waiting for it to break. But it never broke. I only ever see one dialog window on the screen, even though the 'new', 'Create' and 'ShowWindow' are called multiple times in a row. Is this what you would expect? And how would you test this to prove that it's written poorly? Jean Palmer Northrop Grumman > * [EMAIL PROTECTED] > * (410-993-2627) > > _______________________________________________ msvc mailing list [email protected] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
