MainWindow is a singleton

This prevents double instantiation by design rather than by convention.
This commit is contained in:
Raphael Coeffic
2021-04-06 08:51:47 +02:00
parent d8564e3661
commit d1ab02b5c9
+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;
}