nmwsharp / polyscope

A C++ & Python viewer for 3D data like meshes and point clouds
https://polyscope.run
MIT License
1.78k stars 191 forks source link

Base widget class destructor is non virtual #221

Closed dbiswas2808 closed 1 year ago

dbiswas2808 commented 1 year ago

Non virtual base class Widget will never call the derived class destructors resulting in possible leaks.

// A base class for widgets in the scene. These need to be tracked globally so they drawn/handled in the user
// interaction loop. The constructor/destructors take care of inserting the widget in to a global registery.
class Widget {

public:
  Widget();
  ~Widget();

  // No copy constructor/assignment
  Widget(const Widget&) = delete;
  Widget& operator=(const Widget&) = delete;

  virtual void draw();
  virtual bool interact(); // returns true if the mouse input was consumed
  virtual void buildGUI();

}; // namespace polyscope
nmwsharp commented 1 year ago

good spot, merged the corresponding PR. thank you!