bob@odi.COM (Bob Miner) (10/16/90)
XtAppMainLoop() seems to be over-writing part of a c++ class instance. Here are the details: --------- Create an instance of class Class1. Constructor of Class1 creates an athena command widget. Set callback for command widget to be another method in this class. If this is a non-static method, I believe this is your problem. The callback has no way to know which object is the 'this' object, hence it's calling the callback method with a null this. Hence the values for this are bad, as you saw. A better approach is to make all your callback methods static methods and stuff a pointer to your C++ object into the widget's resources (most widgets have something like a XxNuserData resource). When the static callback method is called, get the XxNuserData resource from the widget, cast it to the appropriate C++ type and call a method on that object to handle the event. Constructor of Class1 creates an instance of Class2. Constructor of Class2 initializes one of its slots to zero. Class1 constructor then continues. Print class2.slotvalue --> value is zero (correct). Call XtAppMainLoop(application_context); End of Class1 constructor (I know it enters an infinite loop before it gets to "the end" of constructor). [... stuff deleted ...] Help...? -- ----------------------------------- Bill Patterson pattersw@turing.cs.rpi.edu Computer Science Department Rensselaer Polytechnic Institute Troy, NY. "Jane, you ignorant slut." ----------------------------------- Bob Miner ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Object Design, Inc. ~ OOOOOO 1 New England Executive Park ~ OOOO OOOO Burlington, MA 01803 USA ~ OOOOO OOOOO bob@odi.com -or- uunet!odi!bob ~ OOOO OOOO voice: (617) 270-9797 FAX: (617) 270-3509 ~ OOOOOO bject Design Inc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "From there to here, from here to there, funny things are everywhere." - Dr. Seuss ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~