Crash when OnNewDocument fails !
Danny Lauwers -- dlauwers@innet.be
Saturday, October 12, 1996
Enviroment: WinNT 4.0 / VC4.2
Hello,
I have a Doc/View type application. The NEW of a document does actually
create a new document and fills it with data from an external source (DSP
via SCSI). I do some preparations to make the transfer and call the
DoSave(strName) in the OnNewDocument function that I have overriden. If I
input a valid filename in the filedialog that DoSave(..) generates
everything works OK, and I return TRUE from the OnNewDocument(). When I do a
cancel in the DoSave(..) I skip the data transfer and return a FALSE from
OnNewDocument(). The OnNewDocument returns to its caller
CMultiDocTemplate::OpenDocumentFile
if (!pDocument->OnNewDocument())
{
// user has be alerted to what failed in OnNewDocument
TRACE0("CDocument::OnNewDocument returned FALSE.\n");
pFrame->DestroyWindow();
return NULL;
}
Where the framework enters the if. It tries to destroy the window but that
does not work, this is the chain of calls:
BOOL CMDIChildWnd::DestroyWindow() // is called correctly, inside it...
pFrameWnd->OnUpdateFrameTitle(TRUE); // is called, inside it...
if (bAddToTitle &&
(pActiveChild = MDIGetActive()) != NULL &&
(pActiveChild->GetStyle() & WS_MAXIMIZE) == 0 &&
(pDocument != NULL ||
(pDocument = pActiveChild->GetActiveDocument()) != NULL)) // inside
MDIGetActive...
CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
ASSERT(pWnd == NULL || pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd))); // BOEM
This last line, the FromHandle fails to return a correct pWnd but != NULL so
the IsKindOf blows.
Even if I skip all my extra code in the OnNewDocument and just call the
enherited function only. If I just return a FALSE then, it blows.
Does anybody has a clue what and where it goes wrong here ? I have debugged
it over and over, but I can't seem to find anything.
Thank you
Danny Lauwers
==============================================================================
Ing. Danny Lauwers (dlauwers@innet.be)
Intersoft Electronics Radar verification Hard- & software
Lammerdries 27 Fotofinish and timing of sportevents
2250 Olen Belgium Europe Footscan applications
Tel: +32 14 231811 and more ...
Fax: +32 14 231944 Checkout http://www.innet.be/intersoft
===============================================================================
Brian Jones -- BrianJ@apptechsys.com
Thursday, October 17, 1996
I have been recently trying to debug a very similar problem, but also
with no success. In my case, returning FALSE from a normal
OnOpenDocument also fails out at the same place. Stepping into the
source code has not helped me determine the cause of the crash. I, too,
am running NT 4.0 and using VC 4.2. When my program crashes, I get the
magic blue "you blew out Windows" screen.
Brian Jones
Bremerton, WA
BrianJ@apptechsys.com
>----------
>From: Danny Lauwers[SMTP:dlauwers@innet.be]
>Sent: Saturday, October 12, 1996 7:54 AM
>To: mfc-l@netcom.com
>Subject: Crash when OnNewDocument fails !
>
>Enviroment: WinNT 4.0 / VC4.2
>
>Hello,
>
>I have a Doc/View type application. The NEW of a document does actually
>create a new document and fills it with data from an external source (DSP
>via SCSI). I do some preparations to make the transfer and call the
>DoSave(strName) in the OnNewDocument function that I have overriden. If I
>input a valid filename in the filedialog that DoSave(..) generates
>everything works OK, and I return TRUE from the OnNewDocument(). When I do a
>cancel in the DoSave(..) I skip the data transfer and return a FALSE from
>OnNewDocument(). The OnNewDocument returns to its caller
>CMultiDocTemplate::OpenDocumentFile
>
>if (!pDocument->OnNewDocument())
>{
> // user has be alerted to what failed in OnNewDocument
> TRACE0("CDocument::OnNewDocument returned FALSE.\n");
> pFrame->DestroyWindow();
> return NULL;
>}
>
>Where the framework enters the if. It tries to destroy the window but that
>does not work, this is the chain of calls:
>
>BOOL CMDIChildWnd::DestroyWindow() // is called correctly, inside it...
>
>pFrameWnd->OnUpdateFrameTitle(TRUE); // is called, inside it...
>
>if (bAddToTitle &&
> (pActiveChild = MDIGetActive()) != NULL &&
> (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0 &&
> (pDocument != NULL ||
> (pDocument = pActiveChild->GetActiveDocument()) != NULL)) // inside
>MDIGetActive...
>
>CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
> ASSERT(pWnd == NULL || pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd))); // BOEM
>
>This last line, the FromHandle fails to return a correct pWnd but != NULL so
>the IsKindOf blows.
>
>Even if I skip all my extra code in the OnNewDocument and just call the
>enherited function only. If I just return a FALSE then, it blows.
>
>Does anybody has a clue what and where it goes wrong here ? I have debugged
>it over and over, but I can't seem to find anything.
>
>Thank you
>Danny Lauwers
>
>=============================================================================
>=
>Ing. Danny Lauwers (dlauwers@innet.be)
>Intersoft Electronics Radar verification Hard- & software
>Lammerdries 27 Fotofinish and timing of sportevents
>2250 Olen Belgium Europe Footscan applications
>Tel: +32 14 231811 and more ...
>Fax: +32 14 231944 Checkout http://www.innet.be/intersoft
>=============================================================================
>==
>
>
Danny Lauwers -- dlauwers@innet.be
Friday, November 01, 1996
Hello,
I have found the answer to my bug, in the OnCreate of my ChildWindow (MDI) I
used a setActiveView (CFrameWnd) function to set the active view to one of
my subviews. This was a remainder of a test period that was not deleted.
Removing this line whit the SetActiveView, and I can return FALSE from the
OnOpenDocument without the crash.
Greetings
Danny Lauwers
At 10:25 17/10/96 -0700, you wrote:
>I have been recently trying to debug a very similar problem, but also
>with no success. In my case, returning FALSE from a normal
>OnOpenDocument also fails out at the same place. Stepping into the
>source code has not helped me determine the cause of the crash. I, too,
>am running NT 4.0 and using VC 4.2. When my program crashes, I get the
>magic blue "you blew out Windows" screen.
>
>Brian Jones
>Bremerton, WA
>BrianJ@apptechsys.com
>
>>----------
>>From: Danny Lauwers[SMTP:dlauwers@innet.be]
>>Sent: Saturday, October 12, 1996 7:54 AM
>>To: mfc-l@netcom.com
>>Subject: Crash when OnNewDocument fails !
>>
>>Enviroment: WinNT 4.0 / VC4.2
>>
>>Hello,
>>
>>I have a Doc/View type application. The NEW of a document does actually
>>create a new document and fills it with data from an external source (DSP
>>via SCSI). I do some preparations to make the transfer and call the
>>DoSave(strName) in the OnNewDocument function that I have overriden. If I
>>input a valid filename in the filedialog that DoSave(..) generates
>>everything works OK, and I return TRUE from the OnNewDocument(). When I do a
>>cancel in the DoSave(..) I skip the data transfer and return a FALSE from
>>OnNewDocument(). The OnNewDocument returns to its caller
>>CMultiDocTemplate::OpenDocumentFile
>>
>>if (!pDocument->OnNewDocument())
>>{
>> // user has be alerted to what failed in OnNewDocument
>> TRACE0("CDocument::OnNewDocument returned FALSE.\n");
>> pFrame->DestroyWindow();
>> return NULL;
>>}
>>
>>Where the framework enters the if. It tries to destroy the window but that
>>does not work, this is the chain of calls:
>>
>>BOOL CMDIChildWnd::DestroyWindow() // is called correctly, inside it...
>>
>>pFrameWnd->OnUpdateFrameTitle(TRUE); // is called, inside it...
>>
>>if (bAddToTitle &&
>> (pActiveChild = MDIGetActive()) != NULL &&
>> (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0 &&
>> (pDocument != NULL ||
>> (pDocument = pActiveChild->GetActiveDocument()) != NULL)) // inside
>>MDIGetActive...
>>
>>CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
>> ASSERT(pWnd == NULL || pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd))); // BOEM
>>
>>This last line, the FromHandle fails to return a correct pWnd but != NULL so
>>the IsKindOf blows.
>>
>>Even if I skip all my extra code in the OnNewDocument and just call the
>>enherited function only. If I just return a FALSE then, it blows.
>>
>>Does anybody has a clue what and where it goes wrong here ? I have debugged
>>it over and over, but I can't seem to find anything.
>>
>>Thank you
>>Danny Lauwers
>>
>>=============================================================================
>>=
>>Ing. Danny Lauwers (dlauwers@innet.be)
>>Intersoft Electronics Radar verification Hard- & software
>>Lammerdries 27 Fotofinish and timing of sportevents
>>2250 Olen Belgium Europe Footscan applications
>>Tel: +32 14 231811 and more ...
>>Fax: +32 14 231944 Checkout http://www.innet.be/intersoft
>>=============================================================================
>>==
>>
>>
>
>
==============================================================================
Ing. Danny Lauwers (dlauwers@innet.be)
Intersoft Electronics Radar verification Hard- & software
Lammerdries 27 Fotofinish and timing of sportevents
2250 Olen Belgium Europe Footscan applications
Tel: +32 14 231811 and more ...
Fax: +32 14 231944 Checkout http://www.innet.be/intersoft
===============================================================================
| Вернуться в корень Архива
|