From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Fri Nov 15 2002 - 08:10:21 EST
Hi Kris, Kris Hagel <hagel@comp.tamu.edu> wrote concerning brop monitor seg violations fixed (for now) [Thu, 14 Nov 2002 16:21:22 -0600] ---------------------------------------------------------------------- > Hello, > My thanks to Christian for the magic command for running a program in > gdb with argument. I had spent some time looking for the "trick" and > did not find one and had (begin VMS unrant) finally concluded that unix > debugging was simply not up the high VMS standards of yesteryear. > But alas I learned from Christian that if I go through the proper > cryptic commands in the proper cryptic order that I can do NEARLY > as much as I could in VMS. What was the `cryptic stuff' in what I sent you? `bt'? You can write `backtrace' if you like, but it easier to write `bt' :-) You know - it's also possible to attach a debugger to a running process: shell> <my program> <arguments> & shell> gdb <my program> $! `$!' gives the PID (_not_ `particle identity' but `process identifier') of the latest background (asynchronous) command. You can of course also run the debugger from within GNU Emacs, and Emacs will jump into your source code. This gives you a `visual' debugger. Quite a neat trick too. > Of course in VMS I didn't have to do cryptic stuff; just debugging > and I didn't even have to ask Christian how to do things ... <snicker>Or you could have read the manual</snicker> > ... which is good because he was probably about knee-high to a > jackrabbit when I was doing this advanced VMS debugging (end VMS > unrant). So you're an age-chauvinist :-) Who was it that said that scientific change happen in leaps? (it was Kuhn, in case you didn't know). > Anyway this enabled me to find out where I was getting the seg violation > when I did the popup canvas I described yesterday. So for those of you > who are interested, here is a condensed version of the story. In order > to decide if I had a double click in the pad, I have a simple helper > class which is appended to the pad. Every time the mouse passes over > the pad, the DistanceToPrimitive method of this helper class is called > and I can detect in there if I have a single or double click. Why don't you just connect a handler method to the appropriate signals of the pad? It's is possible to have many handlers connected to a signal - I believe that they are executed in FIFO order, but I'm not sure (check the docs). > I was calling directly from there the routine to pop up the new > canvas, but this generated its own X11 event which caused the > DistanceToPrimitive method of THistPainter to get called when > things were not all the way set up yet. Popping up a window will surely give you a X11 event. > So what I needed to do was to set a flag instead of direcly call the > method and have it inherit from TTimer and do the call finally when > the system was going through the loops in the DispatchOneEvent > method of TSystem. This seems like an awful complicated way of doing a simple thing. Take a look at the attached script and see if that's something you could use. When you double click the main canvas, a `normal' canvas will pop-up with the displayed histogram in it. Closing the `pop-up canvas' will make sure that a new canvas can be created later on. > The important point is to let the canvas go over its entire loop of > fListOfPrimitives before calling something that will modify that. Yes, that this reference problem I was referring to the in the previous email (I think). The point is, that if the memory hasn't been initialised properly, then accessing will of course give the SIGSEGV. Yours, ___ | Christian Holm Christensen |_| | ------------------------------------------------------------- | | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 _| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91 _| Denmark Office: (+45) 353 25 305 ____| Email: cholm@nbi.dk Web: www.nbi.dk/~cholm | | //____________________________________________________________________ // // $Id$ // Author: Christian Holm Christensen <cholm@hehi03.nbi.dk> // Update: 2002-11-15 13:10:44+0100 // Copyright: 2002 (C) Christian Holm Christensen // // //____________________________________________________________________ class MyMain { RQ_OBJECT("MyMain") private: TGMainFrame* fMain; TRootEmbeddedCanvas* fCanvas; TCanvas* fPopup; TH1F* fHist; Bool_t fPopupDown; public: MyMain(); void HandleCanvas(Int_t event, Int_t x, Int_t y); void HandleClose(); }; //____________________________________________________________________ MyMain::MyMain() { fMain = new TGMainFrame(gClient->GetRoot(), 1, 1); fCanvas = new TRootEmbeddedCanvas("Canvas", fMain, 300, 300); fCanvas->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "MyMain", this, "HandleCanvas(Int_t,Int_t,Int_t)"); fMain->AddFrame(fCanvas); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); fMain->MapWindow(); // fPopup = 0; // fPopupDown = kTRUE; fHist = new TH1F("h", "h", 100, -3, 3); fHist->FillRandom("gaus", 10000); fHist->Draw(); fCanvas->GetCanvas()->Modified(); fCanvas->GetCanvas()->Update(); } //____________________________________________________________________ void MyMain::HandleCanvas(Int_t event, Int_t x, Int_t y) { if (event == kButton1Double) { if (!fPopup) { cout << "Creating new canvas" << endl; fPopup = new TCanvas("popup", "Popup Canvas"); fPopup->Connect("Closed()", "MyMain", this, "HandleClose()"); fPopupDown = kFALSE; } else if (!fPopupDown) { cout << "Using old canvas" << endl; fPopupDown = kFALSE; fPopup->Draw(); } fHist->Draw(); } } //____________________________________________________________________ void MyMain::HandleClose() { cout << "Closing pop-up canvas" << endl; if (fPopup) { fPopup = 0; fPopupDown = kTRUE; } } int mymain() { MyMain* myMain = new MyMain; return 0; } //____________________________________________________________________ // // EOF //
This archive was generated by hypermail 2.1.5 : Fri Nov 15 2002 - 08:12:25 EST