File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,19 @@ class G4World : public GBase<G4World>
6363 */
6464 G4World (const GWorld* gworld, const std::shared_ptr<GOptions>& gopts);
6565
66+ // / Frees the owned G4Volume wrappers. Geant4 owns the contained solid/logical/physical
67+ // / objects, so only the lightweight wrappers allocated by the object factories are deleted.
68+ ~G4World () {
69+ for (auto & [name, vol] : g4volumesMap) { delete vol; }
70+ }
71+
72+ // G4World now owns the raw G4Volume* wrappers (freed in the destructor). It is only ever held
73+ // by shared_ptr, so forbid copy/move to avoid a shallow copy double-freeing the wrappers.
74+ G4World (const G4World&) = delete ;
75+ G4World& operator =(const G4World&) = delete ;
76+ G4World (G4World&&) = delete ;
77+ G4World& operator =(G4World&&) = delete ;
78+
6679 // ────── lookup / mutators ────────────────────────────────────────
6780
6881 /* *
You can’t perform that action at this time.
0 commit comments