Xref: utzoo comp.windows.open-look:286 alt.toolkits.xview:77 Path: utzoo!mnetor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!shearson.com!newshost!salc From: salc@aristotle.shearson.com (Sal Cataudella) Newsgroups: comp.windows.open-look,alt.toolkits.xview Subject: Re: XView with C++ Message-ID: Date: 18 Dec 90 16:50:12 GMT References: Sender: news@shearson.com (News) Distribution: all Organization: Lehman Brothers Lines: 58 In-Reply-To: zoo@aps1.spa.umn.edu's message of 16 Dec 90 07:17:13 GMT In article zoo@aps1.spa.umn.edu (david d [zoo] zuhn) writes: Xref: shearson.com comp.windows.open-look:259 alt.toolkits.xview:68 Path: shearson.com!uunet!know!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!gatech!mcnc!shelby!msi.umn.edu!s16.msi.umn.edu!zoo From: zoo@aps1.spa.umn.edu (david d [zoo] zuhn) Newsgroups: comp.windows.open-look,alt.toolkits.xview Date: 16 Dec 90 07:17:13 GMT Sender: news@s1.msi.umn.edu Distribution: all Organization: Minnesota Automated Plate Scanner Lab Lines: 103 I have gotten the XView header files to be compatible with g++ 1.37.2, and now have a problem with a small program that I have written. My intention is to be able to keep a Frame inside of a class object, and all of the callbacks for this object's controls will be methods of the object. My problem is that my quit callback (this is a hello world type program to start with) will crash my program, with a bus error deep in the notifier. I don't have a -g XView, and don't have the disk space to build one if I wanted to. This is probably a bug in my understanding of how and where C++ objects have their memory allocated and deallocated, but I can't figure this out. If someoneout there has an idea of how to do this, please let me know. FWIW: SunOS 4.1, XView 2.0 (with modified headers to allow ANSI C and C++ compilation), g++ 1.37.2a, libg++-1.37.2 david d [zoo] zuhn Univ. of Minnesota Dept. of Astronomy zoo@aps1.spa.umn.edu Automated Plate Scanner Project david the problem is very simple, your quit method is being invoked with a garbage 'this' pointer. As a result when your test::quit() method tries to access data members it is offsetting from *garbage*. Taking the address of the method you want to call back is *not* enough;To callback the method you need to associate it with an object pointer. Suggestion: create a generic callback function that can take as parameters the pointer to the method and the pointer to the object, then execute the method in the context of the specific object. Current C based toolkits are not setup to handle calling back C++ methods. You have to provide the interface which does this. -- Sal Cataudella Internet: salc@sisyphus.shearson.com UUCP: ...!uunet!slcpi!sisyphus!salc (212) 464-8728