|
|
Without the registry info code, the destroy is empty. I commented it all out - still crashes!
thanks.
A peculiar observation:
Atfirst the registry is blank. The app pops up the first thing: a CfileDialogST asking for a location (directory browser). If you hit cancel at this point, things are okay. No crash. Next, you run the app, give it a valid folder, and the main UI comes up. In this UI you can run the same exact function that ran at startup, and the CFileDlg pops up again. Now if you hit cancel, it crashes. I dont know what this means...
Appreciate your help,
ns
|
|
|
|
|
|
When the app crashes, it doesnt die from task manager processes, so I kill it. So I know that when I start the app again (after recompiling or whatever) its the one and only app running...I hope thats what you meant...
Thanks,
ns
|
|
|
|
|
Ummm... These are just guesses:- Try with
AfxGetApp()->m_pMainWnd()->PostMessage(WM_CLOSE) , although I don't think it will work any better.
- What are you doing within
OnDestroy ? Something sensible with your document? Try moving the code to OnClose .
- Is the quit message posted from a thread other than the main thread?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm saving registry info in destroy(). Even if I comment it all out it still crashes. My response to the last post mentions a sequencing detail that might be important...
I only have one thread. I'm in the view class from which I post the message. Its not a multithreaded app.
Thanks so much,
ns
|
|
|
|
|
Could you post the code for the InitInstance method? maybe you're doing weird things there.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
BOOL CTrain1App::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings();
AfxInitRichEdit();
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TRAIN1TYPE,
RUNTIME_CLASS(CTrain1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CTrain1View));
AddDocTemplate(pDocTemplate);
m_pView1Template = pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TRAIN1TYPE,
RUNTIME_CLASS(CTrain1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CDlgLists));
m_pView2Template = pDocTemplate;
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
|
|
|
|
|
I don't see any use of CFileDialogST here (thought you were launching at start up before UI).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry. The code is in a function that is triggered in OnInitDialog (in View) after it queries the registry to see if info exists. If not, this function runs. However this same function can be called from a menu selection once the app is up and running. Its when I cancel at this point, that I get the crash.
Is this clearer. So sorry for miscommunicating...
(I had really wanted the blank UI to come up on which the CFileDlg should sit waiting, but the postmessage I used to trigger my function was having probs, which I fixed with sendmessage, so now it just brings the CFileDlg up instead.)
|
|
|
|
|
Let's keep on rocking. Replace WM_CLOSE with ID_APP_EXIT (and tell us what happens).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ha! It blithely ignored
AfxGetMainWnd()->PostMessage(ID_APP_EXIT);
, same as it does
PostQuitMessage(0) .
At least it doesnt crash. It just doesnt want to terminate!
|
|
|
|
|
Doesnt like plain old PostMessage(ID_APP_EXIT); either
|
|
|
|
|
Well, back to WM_CLOSE then. Another try: omit your OnDestroy and OnClose handlers entirely (i.e, delete them both from the .h and the .cpp of your main frame class). Waiting here
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Got rid of the OnClose() and Destroy() completely. Crashes with WM_CLOSE on cancel:
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
AfxGetMainWnd()->PostMessage(WM_CLOSE);
}
|
|
|
|
|
Into which command handler is this code inserted?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
A menu item in the view class : CTrainView::OnSelectDatabase
The view class is handling it.
|
|
|
|
|
(This is getting surrealistic )
Won't you have by chance forgotten returning from OnSelectDatabase right after posting the quit message? If you have, then more code could be subsequently be executed that is causing the crash.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
So even after posting message (I also tried SendMessage) one needs to return! Esp sendMessage I thought would finish the app off immediately, so no return was needed, but apparently not!
Many many thanks.
ns
|
|
|
|
|
I have to take off for a couple of hours. I truly appreciate all the input. I'll be struggling with this later today, so if you are still around....
|
|
|
|
|
|
I've got a go to a party dinner in a few minutes, so the break's also good for me.
If you don't get to solve the problem and don't mind other's eyes peeping your code, zip your project and send it to me: I'll be able to load it into my VC++ next monday and could do a more thorough check.
Bye
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I didnt do a return; in my code after postmessage. No one (except for the latest post) said I had to.
Now I have
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
AfxGetMainWnd()->PostMessage(WM_CLOSE);
<code>return</code>;
}
and by golly it works. I didnt think or imagine I'd need return.
Sorry if I've been an idiot and wasted everyones time!
ns
|
|
|
|
|
Wow! You'd actually help debug my code!!! I thank you so much for the offer. You resolved it this time, so I hope I can take a raincheck on your offer (too good!) next time I have a perplexing crash! Hope you enjoyed the party.
Thank you,
ns
|
|
|
|
|
I'm glad I was of an help. The party was fine, thanx. Happy programming.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|