Hi, > tfile->Write(); // the sync & tfile member pointers are changed to This should not have any effect on the validity of the pointer tfile. However 'ttree->Fill()' might have an effect (See TTree::ChangeFile). If you data set is large you may have to do while(CheckControl()){ // look at *control GetData(); // Fills ev ttree->Fill(); } tfile = ttree->GetFile(); Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Patrick Marks Sent: Tuesday, June 01, 2004 8:03 AM To: roottalk@pcroot.cern.ch Subject: [ROOT] tfile->Write() kills other class members Hello, I'm working on a Visual c++ data acquistion program and am storing my data to a root file. An object, which does not inherit from a root object manages the data taking, and contains pointers to a TTree, TFile, the DAQ control structures, and a 'sync' struct written to by another thread that controls the data taking. THe control thread inherits from TGMainFrame. Everything works, data is written to my root file. The problem is that when I call tfile->Close() or tfile->Write() from the DAQ object it clobbers the other members of the class. Below is a brief outline of my code. Any ideas why writing or closing the TFile interferes with my object -- the object ownership rules don't seem to suggest that the objects will be owned by the file, though i can't tell for sure. Thanks for any help! Patrick Marks class MyGUI : TGMainFrame { MyDAQ *daq; struct sync *control; } void MyGUI::DoDAQ() { daq = new MyDAQ(); control->status = START; // Some code to start MyDAQ::Run in a new thread } clas MyDAQ { TFile *tfile; TTree *ttree; MyEvent *ev; // Inherits from TObject struct sync *contol; // Some DAQ related members... } void MyDAQ::Run() { Init(); while(CheckControl()){ // look at *control GetData(); // Fills ev ttree->Fill(); } tfile->Write(); // the sync & tfile member pointers are changed to invalid ptrs by this line. // same thing happens if i call tfile->Close() instead tfile->Close() // now this segfaults sync->status = STOPPED; // or this does (whichever comes first) }
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET