Message: Deleting a sub-G4UIdirectory deletes the entire hierarchy Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Deleting a sub-G4UIdirectory deletes the entire hierarchy 

Forum: (Graphical) User Interfaces
Date: 28 Oct, 2009
From: Kevin Lynch <Kevin Lynch>

In my application, I have volumes that I allow my users to turn on and off at run time through the Messenger framework. Works fine.

For some of those volumes, there are additional commands that should be present in the command hierarchy when the volume is enabled, and which I want to remove if the volume is disabled. So in one of my messengers, I have items like the following:

void octupoleMessenger::enable_field_messenger() {
  if( ofmess_ == 0 )
    ofmess_ = new octupoleFieldMessenger(this);
}

void octupoleMessenger::disable_field_messenger() {
  if( ofmess_ != 0 ){
    // FIXME ... this deletes the entire g2MIGTRACE hierarchy!
    delete ofmess_; 
    ofmess_ = 0;
  }
}

The enable_field_messenger call works just fine ... the whole sub-hierarchy appears as expected, and all the commands in it work fine.

The problem is the disable_field_messenger() call. For testing purposes, the destructor of ofmess_ is

octupoleFieldMessenger::~octupoleFieldMessenger(){
  delete ofDirectory_;
}

now, the constructor sets up ofDirectory_ as

  ofDirectory_ = new G4UIdirectory( "/g2MIGTRACE/octupole_coil/field/" );

When the destructor is called, the directory "/g2MIGTRACE" (and all its subdirectories and commands, of course) disappears entirely!

I'm using 4.9.2.p02, but I tried this back in the 4.8 days with the same results. Incidentally, this doesn't seem to be restricted to G4UIdirectory, but to the deletion of ANY G4UIcommand.

Am I doing something wrong, or is this a bug in the library?

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 More: PATCH: Deleting a sub-G4UIdirectory deletes the entire hierarchy   (Kevin Lynch - 29 Oct, 2009)
(_ More: Re: PATCH: Deleting a sub-G4UIdirectory deletes the entire hierarchy   (Kevin Lynch - 29 Oct, 2009)
 Add Message Add Message
to: "Deleting a sub-G4UIdirectory deletes the entire hierarchy"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]