u8g2 icon indicating copy to clipboard operation
u8g2 copied to clipboard

U8G2 class could have virtual destructor

Open RotateAt60MPH opened this issue 4 years ago • 3 comments

Hello!

Nice job on this library. One small suggestion. Could there be a virtual destructor added on the U8G2 class? It should be a simple addition to U8g2lib.h:

virtual ~U8G2(void);

This will allow those who to interact with the library to use a generic U8G2 * instead of having a) to define the library instance only in a global, and b) it makes it easier if you select/change displays at run-time &U8G2 due to some condition, and c) gets rid of the compiler warning.

From what I can tell, all your display-specific derived classes just call the base constructor, so why not have the ability to generic the display, like using an interface?

Thanks!

RotateAt60MPH avatar Apr 06 '20 03:04 RotateAt60MPH

All you points are already possible. Nevertheless, I think we can add the virtual destruct as long as the impact on the code size is not so huge.

olikraus avatar Apr 06 '20 06:04 olikraus

And I guess this could apply to U8X8, as well? :)

You mention that all points are already possible. They are possible, but the compiler warning will always be there.

RotateAt60MPH avatar Apr 06 '20 16:04 RotateAt60MPH

yes...

olikraus avatar Apr 06 '20 16:04 olikraus