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. App doesn't shut down propperly

App doesn't shut down propperly

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 2 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.
  • I Offline
    I Offline
    IGeorgeI
    wrote on last edited by
    #1

    Hey guys My app has a mem leak which results from ExitInstance() not being called when I terminate the program. I have traced into MFC and descovered that in the THRDCORE.cpp file, the following code is causing ExitInstance() to NOT be called. ============================================================== // phase2: pump messages while available do { // pump message, but quit on WM_QUIT if (!PumpMessage()) return ExitInstance(); ============================================================== Does anybody know what some of causes of pumpMessage() to return true?? Thanks George George W Software Developer www.zsystems.ca

    B 1 Reply Last reply
    0
    • I IGeorgeI

      Hey guys My app has a mem leak which results from ExitInstance() not being called when I terminate the program. I have traced into MFC and descovered that in the THRDCORE.cpp file, the following code is causing ExitInstance() to NOT be called. ============================================================== // phase2: pump messages while available do { // pump message, but quit on WM_QUIT if (!PumpMessage()) return ExitInstance(); ============================================================== Does anybody know what some of causes of pumpMessage() to return true?? Thanks George George W Software Developer www.zsystems.ca

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      If your message pump processes a WM_QUIT, then the GetMessage returns false. Per MSDN --- "What Is WM_QUIT? Normal message-processing loops in an application's WinMain routine usually exit when the GetMessage function returns a FALSE value. Internally, if GetMessage is about to return a WM_QUIT message, it returns FALSE instead of TRUE even though the message returned in the MSG structure (a WM_QUIT message) is valid. The only time GetMessage will ever return a FALSE value is when it is returning a WM_QUIT message. Conversely, PeekMessage returns WM_QUIT messages as it would any other message. Applications that use PeekMessage in their main message-processing loop must explicitly look for the WM_QUIT message. The PostQuitMessage function does not actually post a WM_QUIT message to the application's task queue. Instead, it sets a flag that is tested inside GetMessage and PeekMessage. WM_QUIT is returned when GetMessage or PeekMessage detects that this flag is set and no other messages or events are pending for the application."

      I 1 Reply Last reply
      0
      • B Blake Miller

        If your message pump processes a WM_QUIT, then the GetMessage returns false. Per MSDN --- "What Is WM_QUIT? Normal message-processing loops in an application's WinMain routine usually exit when the GetMessage function returns a FALSE value. Internally, if GetMessage is about to return a WM_QUIT message, it returns FALSE instead of TRUE even though the message returned in the MSG structure (a WM_QUIT message) is valid. The only time GetMessage will ever return a FALSE value is when it is returning a WM_QUIT message. Conversely, PeekMessage returns WM_QUIT messages as it would any other message. Applications that use PeekMessage in their main message-processing loop must explicitly look for the WM_QUIT message. The PostQuitMessage function does not actually post a WM_QUIT message to the application's task queue. Instead, it sets a flag that is tested inside GetMessage and PeekMessage. WM_QUIT is returned when GetMessage or PeekMessage detects that this flag is set and no other messages or events are pending for the application."

        I Offline
        I Offline
        IGeorgeI
        wrote on last edited by
        #3

        That is pure GOLD! Thank you....I have been struggling with this problem for a while. I knew exactly where to look as soon as I read that. Problem fixed! Thanks again IGeorgeI George W Software Developer www.zsystems.ca

        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