Print Page | Close Window

Calender event Smart Pointer crash.

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=17533
Printed Date: 03 May 2024 at 8:19pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Calender event Smart Pointer crash.
Posted By: Algae
Subject: Calender event Smart Pointer crash.
Date 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!





Replies:
Posted By: Marco1
Date Posted: 08 November 2010 at 8:48am
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...


-------------
Product: XTP 18.3.0 on VS 2017
Platform: VS 2017 / Windows 10 (64bit)


Posted By: Algae
Date Posted: 07 December 2010 at 5:21pm
Thanks Marco,

I expected the answer you gave as that's what I would have suggested too Smile

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.





Posted By: Algae
Date Posted: 14 December 2010 at 4:52pm
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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net