Mysterious crash on DestroyWindow()

This is a discussion on Mysterious crash on DestroyWindow() within the Game Programming forums, part of the General Programming Boards category; Hey everyone, I have a problem (yes, I always do ). This is my code: Code: void gameShutdown() { ShowCursor(TRUE); ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Mysterious crash on DestroyWindow()

    Hey everyone, I have a problem (yes, I always do ). This is my code:
    Code:
    void gameShutdown()
    {
    	ShowCursor(TRUE);
    
    	gfx.shutdown();
    	DestroyWindow(hWnd); // <--- Crashes!
    }
    
    void GFX::shutdown()
    {
    	SAFE_RELEASE(sfcBack);
    	SAFE_RELEASE(sfcFront);
    	SAFE_RELEASE(lpdd);
    }
    If I take out the DestroyWindow(), it will quit normally. If I leave it in, it will give me an illegal operation ("invalid page fault"). DestroyWindow() is not called anywhere else in the program; and also, the same code minus the ShowCursor() worked fine in another project. Does anybody have an idea of what's wrong?

    P.S. I've attached a screenshot of what it shows when I hit debug...
    Attached Images Attached Images  
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    try postquitmessage(0) just before it, I think

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    You mean just before DestroyWindow()?... Actually, gameShutdown() is called after the message loop, so I don't see how the WM_QUIT message could be handled... I'll try it anyways though.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm, nope. Same problem Any other ideas?

    **EDIT**
    Hey, would there be a memory leak if I just left DestroyWindow() out? I mean, could it be that DirectX already Destroy'd the window when I released lpdd?
    Last edited by Hunter2; 02-03-2003 at 07:03 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    are you sure gfx.shutdown doesn't destroy the window, maybe you should post its source too

    i don't know if leaving out destroywindow would cause a memory leak

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    What?
    are you sure gfx.shutdown doesn't destroy the window, maybe you should post its source too
    Mmm, I did, but I'll post the SAFE_RELEASE() code too.

    Code:
    #define SAFE_RELEASE(obj) \
    {\
    	if((obj) != NULL)\
    	{\
    		(obj)->Release();\
    		(obj) = NULL;\
    	}\
    }
    
    void GFX::shutdown()
    {
    	SAFE_RELEASE(sfcBack);
    	SAFE_RELEASE(sfcFront);
    	SAFE_RELEASE(lpdd);
    }
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Weeeiiird! It just mysteriously quit normally... Maybe some of the code didn't quite get re-built earlier or something. Oh well, thanks for the help anyways, silvercord!
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    Weeeiiird! It just mysteriously quit normally... Maybe some of the code didn't quite get re-built earlier or something. Oh well, thanks for the help anyways, silvercord!
    I know I've had similar problems, but I could not remember what they were and I didn't want to keep giving suggestions because I didn't remember, sorry I couldn't actually solve the problem when you had it, and i hope your problem stays out for good.

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Yup, seems like the problem's gone for good!
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. Hooking Crash?
    By Elysia in forum Windows Programming
    Replies: 9
    Last Post: 03-15-2008, 02:13 PM
  3. Can not debug a crash
    By hannibar in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2007, 11:02 AM
  4. Dynamic array sizing causes crash
    By Mithoric in forum C++ Programming
    Replies: 3
    Last Post: 12-30-2003, 07:46 AM
  5. FYI: asctime(gmtime(&mytime)) = crash!
    By anonytmouse in forum C Programming
    Replies: 2
    Last Post: 09-29-2003, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21