Skip to content

Commit

Permalink
fix demisjohn#23: object keeps a reference to local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jsenellart committed Mar 21, 2023
1 parent 520c1c6 commit e340dcb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions camfr/waveguide.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ class Waveguide
{
public:

Waveguide(bool uniform_=false, Material* core_=NULL)
: uniform(uniform_), core(core_) {}

virtual ~Waveguide() {interface_cache.deregister(this);} // Important!
Waveguide(bool uniform_=false, Material* core_=NULL): uniform(uniform_), core(new Material(*core_)) {}

virtual ~Waveguide() {
delete core;
interface_cache.deregister(this); // Important!
}

bool is_uniform() const {return uniform;}
Material* get_core() const {return core;}
Expand Down

0 comments on commit e340dcb

Please sign in to comment.