Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Cleaning non-modal dialog

Cleaning non-modal dialog

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelptutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    Hi all of you. I am currently working on somebody code. And I encountered a strange problem: when I am trying to clean up the non-modal dialog, I get crashing code. Here is the code:

    void CWaitDlg::PostNcDestroy()
    {
    CDialog::PostNcDestroy();

    if(m\_bIsDynamicallyAlocated)
    	delete this;
    

    }

    when the code arrive to "delete this", is crashing: access violation. Because is NULL. Ok, then I test if is NULL, and if it is, I don't delete it:

    void CWaitDlg::PostNcDestroy()
    {
    CDialog::PostNcDestroy();

    if(m\_bIsDynamicallyAlocated && NULL != this && NULL != GetSafeHwnd())
    	delete this;
    

    }

    this time it doesn't crash, (the execution doesn't pass by "delete this") but when the project is ending, I get memory leaks, where it created:

    CWaitDlg* pWaitDlg = new CWaitDlg;

    I have to tell you more: this dialog are used in hidden mode, as an thread. (I repeat, it is not my code). Could you give me an hint how to overcome this ? Thank you.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups