Menu

SetTimer on CDocker::OnDockActivated

2015-01-30
2015-01-31
  • Daniel Pantea

    Daniel Pantea - 2015-01-30

    Hi David,
    my test application is based on Frame sample.
    I gave a test with VLD and didn't find any memory leaks. Then I tried the Deleaker (trial, to hunt GDI and other leaks) and this complained about the TIMER_ID1/2 timers leaking from CDocker::OnDockActivated. They might be false findings, but tried to understand why I need the timers when I don't use any docking features anyway.
    Then I modified CDocker::OnDockActivated and added this first following line:

    if(GetAllDockChildren()->size() == 0) return 0L;
    

    So the idea is to not start the timers if we anyway don't need them (DrawAllCaptions will have some work only if GetAllDockChildren() is not empty).
    After that Deleaker was happy and said "No leaks found": do you think the leak finding is real? Also do you believe is ok to avoid starting the timers if we don't need them?
    Thank you,
    Daniel

     
  • David

    David - 2015-01-31

    Hi Daniel,

    Thanks for your message. I test for these things too, but its pleasing you are able to confirm that the application has no memory leaks or GDI leaks.

    One could argue that window timers can't leak because they are destroyed when the window is destroyed. Having said that, it is considered good practice to kill the timers before the window is destroyed, so I've added a KillTimer to CDocker::OnDestroy.

    It should also be noted that these are one shot timers. They fire just once when the docker (or frame) is activated and are killed when the first WM_TIMER is received.

    Best regards,
    David

     

Log in to post a comment.