🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #32

Help! what does ExecDialog really do?

#32
From: Koh Thong Hwee
Date: Wed, 28 Oct 1992 03:37
62 lines
2729 bytes
[ Article crossposted from comp.lang.c++ ]
[ Author was Koh Thong Hwee ]
[ Posted on Tue, 27 Oct 1992 09:58:54 GMT ]

Hi OWL programmers,

I have a serious bug in my BC++ program that caused a "General Protection
Fault" and I have no idea what the actual fault is.  I hope someone can
help me out.

Here's part of the OWL code :
-------------------------------------------------------------------------

class TObjectA: public TDialog, public TObjectB
{
   ...
   TObjectA(PTWindowsObject AParent, int ResourceId);
   virtual void foo();
   ...
};

...
...

void TAppWind::CMTest(RTMessage Msg)
{
   PtrA = new TObjectA(this, ID_AOBJ);
   PtrA->foo();		//1st call here executes OK
   GetApplication()->ExecDialog(PtrA);
   PtrA->foo();		//2nd call causes UAE
   ...
}

-------------------------------------------------------------------------

I have the pointer, PtrA, printed out before and after calling ExecDialog()
and they are the same.  Yet, the first call to foo() is OK but not the
second call!  I tried using the TDW to debug it and it gives me an Exception
13 error with codes -16844 or -16856.  According to the online help,
this is an addressing fault.  I single stepped through the program and I
could pinpoint the offending instruction as the 2nd call to foo().  It
appears that ExecDialog() must have caused some variables to change such
that the following instruction is no more valid.  ExecDialog() itself
executes OK -- it puts up the dialog box alright.

Does anyone know if quitting from ExecDialog() also deletes the dialog
object (ie invalidates PtrA)?  I can't seem to find any mention of this
in the OWL manual.  In any case, I thought an object created using the
new operator needs to be destroyed by the delete operator explicitly. 
(So PtrA should still be valid for the second call to foo() right?)

If quitting from a dialog box also destroyed the object, then how can I
create my own objects that also needs to incorporate all those interface
elements of MS Windows?  The lifetime of my object will definitely need
to be longer than that of a dialog box that it uses to gather extra input
from the user.  I must be missing something somewhere...

Any help is most welcomed...

Thanx in advance,
TH Koh
gthkoh@ntuix.ntu.ac.sg
Technical Details
Message-ID: <1992Oct28.033726.21609@ntuix.ntu.ac.sg>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!yale.edu!jvnc.net!nuscc!ntuix!gthkoh

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!yale.edu!jvnc.net!nuscc!ntuix!gthkoh
From: gthkoh@ntuix.ntu.ac.sg (Koh Thong Hwee)
Subject: Help! what does ExecDialog really do?
Message-ID: <1992Oct28.033726.21609@ntuix.ntu.ac.sg>
Organization: Nanyang Technological University - Singapore
X-Newsreader: TIN [version 1.1 PL6]
Date: Wed, 28 Oct 1992 03:37:26 GMT
Lines: 63