Skip to content

Commit 4fbc532

Browse files
committed
Fixed issues causing ESP to restart
1 parent 5723d82 commit 4fbc532

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

Drawable.cpp

+8-16
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ const char *Circle::type() const
2020

2121
Circle::~Circle()
2222
{
23-
if (this != nullptr)
24-
delete this;
23+
// delete this;
2524
}
2625

2726
Rectangle::Rectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t cornerRadius, uint8_t thickness)
@@ -39,8 +38,7 @@ const char *Rectangle::type() const
3938

4039
Rectangle::~Rectangle()
4140
{
42-
if (this != nullptr)
43-
delete this;
41+
// delete this;
4442
}
4543

4644
Line::Line(uint8_t startX, uint8_t startY, uint8_t endX, uint8_t endY, uint8_t thickness)
@@ -58,8 +56,7 @@ const char *Line::type() const
5856

5957
Line::~Line()
6058
{
61-
if (this != nullptr)
62-
delete this;
59+
// delete this;
6360
}
6461

6562
Bitmap::Bitmap(const uint8_t *dataSet, uint8_t x, uint8_t y, uint8_t width, uint8_t height)
@@ -77,8 +74,7 @@ const char *Bitmap::type() const
7774

7875
Bitmap::~Bitmap()
7976
{
80-
if (this != nullptr)
81-
delete this;
77+
// delete this;
8278
}
8379

8480
Text::Text(String text, uint8_t x, uint8_t y)
@@ -96,8 +92,7 @@ const char *Text::type() const
9692

9793
Text::~Text()
9894
{
99-
if (this != nullptr)
100-
delete this;
95+
// delete this;
10196
}
10297

10398
HighlightedText::HighlightedText(String text, uint8_t x, uint8_t y)
@@ -115,8 +110,7 @@ const char *HighlightedText::type() const
115110

116111
HighlightedText::~HighlightedText()
117112
{
118-
if (this != nullptr)
119-
delete this;
113+
// delete this;
120114
}
121115

122116
AnimatedText::AnimatedText(String text, uint8_t x, uint8_t y, int delay, bool highlight)
@@ -134,8 +128,7 @@ const char *AnimatedText::type() const
134128

135129
AnimatedText::~AnimatedText()
136130
{
137-
if (this != nullptr)
138-
delete this;
131+
// delete this;
139132
}
140133

141134
GridView::GridView(Drawable *drawable, uint8_t count, uint8_t countPerLine, uint8_t startX, uint8_t startY, uint8_t seperationX, uint8_t seperationY)
@@ -239,6 +232,5 @@ const char *GridView::type() const
239232

240233
GridView::~GridView()
241234
{
242-
if (this != nullptr)
243-
delete this;
235+
// delete this;
244236
}

Fragment.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ void Fragment::add(Drawable *drawable)
3636
for (int i = 0; i < drawableCount; ++i)
3737
{
3838
newDrawables[i] = drawables[i];
39+
yield();
3940
}
40-
delete[] drawables;
41+
if (drawables != nullptr)
42+
delete[] drawables;
4143
drawables = newDrawables;
4244
}
4345
drawables[drawableCount++] = drawable;

Fragments.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class Fragment
219219
{
220220
private:
221221
FragmentManager &manager;
222-
Drawable **drawables;
222+
Drawable **drawables = nullptr;
223223
uint8_t drawableCount;
224224
uint8_t drawableCapacity;
225225
uint8_t lastCount = 0;

SSD1306.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ void OLED::circle(uint8_t centerX, uint8_t centerY, uint8_t radius, uint8_t thic
949949
drawPixel(centerX - y, centerY + x);
950950
drawPixel(centerX + y, centerY - x);
951951
drawPixel(centerX - y, centerY - x);
952+
yield();
952953
}
953954
radius--;
954955
}

0 commit comments

Comments
 (0)