Click here to Skip to main content
16,007,087 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Way to tell which process last wrote to a file? Pin
Cristian Amarie30-Dec-06 7:04
Cristian Amarie30-Dec-06 7:04 
QuestionMessage Removed Pin
29-Dec-06 11:31
Armond Sarkisian29-Dec-06 11:31 
AnswerRe: Opening a dialogue window Pin
Hamid_RT29-Dec-06 17:10
Hamid_RT29-Dec-06 17:10 
AnswerRe: Opening a dialogue window Pin
Joan M30-Dec-06 2:34
professionalJoan M30-Dec-06 2:34 
QuestionDriver installation checking Pin
RomTibi29-Dec-06 10:57
RomTibi29-Dec-06 10:57 
AnswerRe: Driver installation checking Pin
Ralf Lohmueller29-Dec-06 14:53
Ralf Lohmueller29-Dec-06 14:53 
GeneralRe: Driver installation checking Pin
RomTibi29-Dec-06 19:25
RomTibi29-Dec-06 19:25 
QuestionVC++6 InitInstance strange thing? Pin
Joan M29-Dec-06 9:59
professionalJoan M29-Dec-06 9:59 
Sorry, I've not been able to place here a better title...

Hello all,

A strange thing that deserves a code sample and somebody that know what could happen... (this is not me).



BOOL CTCC::InitInstance()
{
  m_pLogAE = new A;
  m_pXmlAEInternal = new B;
  m_pXmlConfig = new C;

  if (!FunctionX() ||
      !m_pControl->FunctionY() ||
      !m_pXmlFile->LoadFile(csPath, csReason))
  {
    DoSomething();
  }
  else
  {
    CTCCDlg dlg;
    m_pMainWnd = &dlg;
  
    dlg.DoModal();

    m_pControl->RestoreSettings(); // POINT 1

    if(m_pLogAE)          delete m_pLogAE;
    if(m_pXmlAEInternal)  delete m_pXmlAEInternal;
    if(m_pXmlConfig)      delete m_pXmlConfig;
  }

  // POINT 2
  if(m_pLogAE)          delete m_pLogAE;
  if(m_pXmlAEInternal)  delete m_pXmlAEInternal;
  if(m_pXmlConfig)      delete m_pXmlConfig;

  // Since the dialog has been closed, return FALSE so that we exit the
  //  application, rather than start the application's message pump.
  return FALSE;


As you can see there is a terrible design: I've repeated some code: after the POINT 1 there are three lines that should be only after the POINT 2 as they are intended to clear some memory that has been filled before the first if clause.

It surprises me a lot, but if I place a breakpoint in the line where POINT 1 is, I can see how the application continues until the bracket that is before POINT 2 "}". If I remove the code that is before that bracket and after POINT 1, and execute again the code I can see how if the code reach that bracket it gets stopped again and don't go further the POINT 2.

Any idea?

Thank you in advance.

PS: I've made a "Clean" and a "Rebuild All".
AnswerRe: VC++6 InitInstance strange thing? Pin
David Crow29-Dec-06 10:07
David Crow29-Dec-06 10:07 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M29-Dec-06 10:14
professionalJoan M29-Dec-06 10:14 
GeneralRe: VC++6 InitInstance strange thing? Pin
David Crow29-Dec-06 10:24
David Crow29-Dec-06 10:24 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M29-Dec-06 10:36
professionalJoan M29-Dec-06 10:36 
GeneralRe: VC++6 InitInstance strange thing? Pin
David Crow29-Dec-06 10:46
David Crow29-Dec-06 10:46 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M29-Dec-06 10:56
professionalJoan M29-Dec-06 10:56 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M30-Dec-06 2:40
professionalJoan M30-Dec-06 2:40 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M29-Dec-06 10:15
professionalJoan M29-Dec-06 10:15 
AnswerRe: VC++6 InitInstance strange thing? [modified] Pin
Cristian Amarie29-Dec-06 22:53
Cristian Amarie29-Dec-06 22:53 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M30-Dec-06 2:39
professionalJoan M30-Dec-06 2:39 
AnswerRe: VC++6 InitInstance strange thing? Pin
Gary R. Wheeler30-Dec-06 3:44
Gary R. Wheeler30-Dec-06 3:44 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M30-Dec-06 3:49
professionalJoan M30-Dec-06 3:49 
GeneralRe: VC++6 InitInstance strange thing? Pin
Gary R. Wheeler30-Dec-06 8:23
Gary R. Wheeler30-Dec-06 8:23 
GeneralRe: VC++6 InitInstance strange thing? Pin
Joan M30-Dec-06 8:33
professionalJoan M30-Dec-06 8:33 
QuestionImage compression? Pin
Dave Calkins29-Dec-06 9:27
Dave Calkins29-Dec-06 9:27 
AnswerRe: Image compression? Pin
Dave Calkins29-Dec-06 9:30
Dave Calkins29-Dec-06 9:30 
GeneralRe: Image compression? (not a real answer) Pin
Joan M29-Dec-06 10:02
professionalJoan M29-Dec-06 10:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.