Xref: utzoo comp.windows.open-look:277 alt.toolkits.xview:76 Path: utzoo!attcan!utgpu!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 Subject: XView with C++ Message-ID: 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 ------------------ The sample code -------------- #include #include #include #include #include #include class Test { public: Test(int width, int height); ~Test(); int quit (Panel_item item, Event *event); Frame frame; Panel panel; }; Test::Test(int width, int height) { frame = (Frame) xv_create (NULL, FRAME, XV_WIDTH, width, XV_HEIGHT, height, NULL); panel = (Panel) xv_create (frame, PANEL, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL); (void) xv_create (panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Quit", PANEL_NOTIFY_PROC, quit, NULL); } Test::~Test() { if (frame) cout << "frame\n"; else cout << "no frame\n"; } int Test::quit (Panel_item item, Event *event) { xv_destroy_safe (frame); return XV_OK; } int main (int argc, char *argv[]) { Test *test; xv_init (XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL); test = new Test (800, 400); xv_main_loop (test->frame); delete test; return 0; } ---------------- The post mortem ------------------ #0 0x2fbc in xv_destroy_status () #1 0x5c58 in notify_destroy () #2 0x163f4 in ndis_default_prioritizer () #3 0x5954 in notify_client () #4 0x6078 in ndis_default_scheduler () #5 0x1bb88 in xv_scheduler_internal () #6 0x53bc in ndis_dispatch () #7 0x14538 in notify_start () #8 0xbd98 in xv_main_loop () #9 0x24d0 in main (argc=1, argv=0xf7fffc84) (xv.cc line 64)