#35 ATL Bug: deleting object in OnFinalMessage can cause a crash

open
None
5
2004-10-12
2004-10-12
Nenad Stefanovic
No

ATL::CWindowImpl provides an overrideable method
OnFinalMessage which can be used to delete an object.
OnFinalMessage will be called when a window is
destroyed and all messages are processed. However,
the implementation of CWindowImpl::WindowProc is not
correct, which can lead to a crash, especially in multi-
threaded projects.

This is an ATL bug, and not a WTL one, but it is
included here for two reasons: because it directly
impacts WTL projects (for example, MDI projects use
OnFinalMessage), and because WTL might need to find a
way to fix this.

Submitted by Pavel Mosunov

Discussion

  • Logged In: NO

    This bug has been fixed in ATL 7.x, albeit with a twist. I have
    a FAQ article about it along with a fix - you may want to
    check it out:

    http://www.mvps.org/vcfaq/com/10.htm

    Comment by:
    Alexander Nickolov
    agnickolov@mvps.org

     
  • Logged In: YES
    user_id=1025101

    Hi Alexander,

    Thank you for your solution. I will take it into account.

    The bug described here is for ATL 7.x, and the fix for it is to
    move the lines to reset current message after calling
    DefWindowProc. The more info about it was posted to the
    WTL list on Yahoo Groups
    (http://groups.yahoo.com/group/wtl).

    Thanks,
    Nenad

     
  • Logged In: NO

    sin comentarios