Problem 1087 - G4UIcommandTree::RemoveCommand() incorrectly deletes directories
Summary: G4UIcommandTree::RemoveCommand() incorrectly deletes directories
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: intercoms (show other problems)
Version: 9.2
Hardware: All All
: P5 normal
Assignee: Koichi Murakami
URL: http://hypernews.slac.stanford.edu/Hy...
Depends on:
Blocks:
 
Reported: 2009-10-30 03:16 CET by Kevin Lynch
Modified: 2009-11-06 07:20 CET (History)
0 users

See Also:


Attachments
diff -u patch against intercoms/src/G4UIcommandTree.cc (567 bytes, patch)
2009-10-30 03:16 CET, Kevin Lynch
Details | Diff

Note You need to log in before you can comment on or make changes to this problem.
Description Kevin Lynch 2009-10-30 03:16:04 CET
Created attachment 54 [details]
diff -u patch against intercoms/src/G4UIcommandTree.cc

G4UIcommandTree::RemoveCommand() incorrectly deletes "empty" directories because of an incorrect definition of "empty".  The definition used in the distribution is "directory contains no commands"; the definition should also require "directory contains no sub-directories".  

Consider the following simple directory structure

/a/b/c/D
/a/b/e/F

For clarity, lowercase letters denote directories, and capitalized letters denote "true" commands.  In the 9.2.p02 distribution, if you delete the G4UIcommand associated with "D", G4UIcommandTree::RemoveCommand() will first delete "D"

/a/b/c/
/a/b/e/F

"c" is now empty, so lines 135-153 will remove it from the commandTree

/a/b/
/a/b/e/F

and next check "b".  "b" still has "e" as a member, but "e" is not counted, as the test is only for "commands" not "trees", so /a/b/ is considered empty and removed, leaving

/a/

which is clearly empty.  Deleting "D" has immolated the entire hierarchy!

Removal of hierarchies at run time is a useful behavior, so this bug, while pretty trivial, is really annoying.  I have a number of volumes that can be added by the user through a G4UIcommand at runtime.  These volumes have additional commands associated with them that I don't want to appear unless the volumes exist; similarly, I want the commands to go away if the volumes are removed.

The attached patch corrects this problem without changing the interface; see also the referenced hypernews postings.
Comment 1 Koichi Murakami 2009-11-06 07:19:32 CET
Thanks for your kind report.

It will be fixed in the 9.3 release as you suggested.