Merge pull request #10 from raphaelcoeffic/mainwindow-singleton

MainWindow is a singleton
This commit is contained in:
Bertrand Songis
2021-04-06 09:17:04 +02:00
committed by GitHub
+6 -2
View File
@@ -25,15 +25,16 @@
class MainWindow: public Window
{
public:
// singleton
MainWindow():
Window(nullptr, {0, 0, LCD_W, LCD_H}),
invalidatedRect(rect)
{
Layer::push(this);
_instance = this;
}
public:
~MainWindow() override
{
children.clear();
@@ -41,6 +42,9 @@ class MainWindow: public Window
static MainWindow * instance()
{
if (!_instance)
_instance = new MainWindow();
return _instance;
}