Calender event Smart Pointer crash. |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 06 November 2010 at 2:12pm |
This has been bothering me for a long time. Maybe I'm missing something really obvious.
My program can close while the event properties dialog is still open. The program will crash when exiting because of the event smart pointer in the dialog. See m_ptrEditingEvent in the Calendar sample. I can't seem to get rid of this pointer cleanly. I have tried every method of release and destruct and detach I can think of and nothing seems to work. I don't, and cannot, create a reference to the event dialog to refer back to it and close it. Based on the program design of being able to open multiple event dialogs concurrently that isn't an option. Is there a way I can get rid of this pointer before the view/controller etc. goes away? Thanks if you can help! |
|
Marco1
Senior Member Joined: 16 January 2004 Location: Germany Status: Offline Points: 251 |
Post Options
Thanks(0)
|
Sorry to say, but it sounds like a bad design for me.
If the program (with its calendar event database) closes, the pointers of the dialog get invalid and point to nowhere. The correct closing order should be to close all open (nonmodal) prop dialogs first and then the main program. 1. I guess you have a handler somewhere which creates the nonmodal dialog. You should store the pointer to the new dialog in a vector somewhere in the mainfraime/app and iterate through this list in OnClose (or whatever) and destruct all open dialogs properly. 2. Or you derive your own prop dlg class which registers itself in the vector (e.g. in ctor / OnCreate). Getting a pointer to the main wnd is always possible. Closing the prop dlg removes the pointer out of the vector. I'm aware you said you don't have and cannot create a ref to the dialog - but you should... |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Thanks Marco,
I expected the answer you gave as that's what I would have suggested too That means I'll likely have to create a list of dialog references and push/pop them just for the calendar module. Ugly bunch of overhead for the one time shutdown process in case all the event dialogs aren't closed. I don't know exactly why the calendar behaves differently as I use the same nonmodal construct everywhere without ill effect. |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
After implementing a list of dialog pointers and closing on exit, I can say..
that's not it! My dialogs cleaned up fine without all that. There's some kind of pointer or sink or something that calendar wants to hang onto. Back to the drawing board. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |