[pdp-discuss] TypeAccess question?
Richard Jones
dickjr at gmail.com
Wed Nov 15 09:02:39 MST 2006
Thanks for the reply. Unfortunately, it doesn't help. In the
TypeDef::GetValStr(...) I'm still getting an EXC_BAD_ACCESS on the
last of the following lines:
...
if(DerivesFrom(TA_taBase)) {
TAPtr rbase = *((TAPtr*)base);
if((rbase != NULL) && ((rbase->GetOwner() != NULL) || (rbase ==
tabMisc::root))) {
One thing I did try, based on the first sentences of section 18.12 in
the help: "If a class contains a pointer to another object, it should
typically refer to that object whenever the pointer is set. The
interface assumes that this is the case, ..." was to put a dumb check
for equality to NULL right after setting my pointer to NULL in my
Initialize() function. This seems to fix the problem but I don't see
why, and I haven't yet exhaustively verified this.
Does this seem like it should work?
On 11/14/06, Randall C. O'Reilly <Randy.OReilly at colorado.edu> wrote:
> I bet the SIMPLE_COPY doesn't handle the memberdef* case correctly -- try
> getting rid of that to see if that is the source of the problem. if so,
> replace with:
>
> void Copy_(const TestLayer& cp) { var_md = cp.var_md; }
>
> - Randy
>
> On Tuesday 14 November 2006 18:58, Richard Jones wrote:
> > I've been having a recurring problem with my code. Every now and then
> > I am getting core dumps while in executing in:
> >
> > String TypeDef::GetValStr(...)
> >
> > This will usually be when I want to open an edit dialog on a newly
> > created object, such as a layer. It also happens if I try to save my
> > project after newly creating an object. This latter is a disaster
> > since it writes out a corrupt proj.gz file and work is lost. It
> > doesn't happen under all circumstances, but I've got it boiled down to
> > reproducibility. Consider the following class:
> >
> > class TestLayer : public Layer {
> >
> > public:
> >
> > MemberDef* var_md;
> >
> > void UpdateAfterEdit() {};
> > void Initialize() { var_md = NULL;};
> > void Destroy() { };
> > void InitLinks() {};
> > SIMPLE_COPY(TestLayer);
> > COPY_FUNS(TestLayer, Layer);
> > TA_BASEFUNS(TestLayer);
> > };
> >
> > If in NetViewer I create just one TestLayer and then try to edit it I
> > have no problem. If I create two and try to edit the first, again no
> > problem. But if I try to edit the second I get the dump. Creating
> > one at a time doesn't seem to be a problem, most of the the time.
> >
> > The problem is related to my inclusion of pointers to taBase classes.
> > For instance, if I remove the "MemberDef* var_md" above the problem
> > goes away. There must be something I'm supposed to do but am
> > missing. Any advice I could get would be greatly welcome.
> >
> > Many thanks.
>
--
Richard Jones
dickjr at gmail.com
More information about the PDP-Discuss
mailing list