Skip to content

Commit

Permalink
only free font in destructor -> fixes allocation error on switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Jahn committed Nov 11, 2023
1 parent 0746dae commit 64283c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/displayapp/screens/WatchFaceStarTrek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ WatchFaceStarTrek::WatchFaceStarTrek(Controllers::DateTime& dateTimeController,
font_time = &jetbrains_mono_extrabold_compressed;
} else {
if (starTrekFontAvailable) {
font_time = lv_font_load("F:/fonts/edge_of_the_galaxy.bin");
font_StarTrek = lv_font_load("F:/fonts/edge_of_the_galaxy.bin");
font_time = font_StarTrek;
} else {
font_time = &jetbrains_mono_extrabold_compressed;
}
Expand All @@ -117,8 +118,8 @@ WatchFaceStarTrek::WatchFaceStarTrek(Controllers::DateTime& dateTimeController,
WatchFaceStarTrek::~WatchFaceStarTrek() {
lv_task_del(taskRefresh);

if (starTrekFontAvailable && !settingsController.GetStarTrekUseSystemFont() && font_time != nullptr) {
lv_font_free(font_time);
if (font_StarTrek != nullptr) {
lv_font_free(font_StarTrek);
}

lv_obj_clean(lv_scr_act());
Expand Down Expand Up @@ -453,7 +454,7 @@ void WatchFaceStarTrek::Refresh() {
};
lv_obj_realign(weatherIcon);
}
weatherNeedsRefresh = false;
weatherNeedsRefresh = false;
} else {
lv_label_set_text_static(temperature, "--");
lv_label_set_text(weatherIcon, "");
Expand Down Expand Up @@ -761,18 +762,16 @@ void WatchFaceStarTrek::UpdateSelected(lv_obj_t* object, lv_event_t event) {
// ST font was not used and shall be used now
if (starTrekFontAvailable && usedSystem) {
lv_label_set_text_static(lblSetUseSystemFont, WANT_ST_FONT);
font_time = lv_font_load("F:/fonts/edge_of_the_galaxy.bin");
// give font time to be loaded, this can possibly be lowered
vTaskDelay(100);
if (font_StarTrek == nullptr) {
font_StarTrek = lv_font_load("F:/fonts/edge_of_the_galaxy.bin");
}
font_time = font_StarTrek;
updateFontTime();
usedSystem = false;
}
// ST font was used and gets deactivated
else if (starTrekFontAvailable && !usedSystem) {
lv_label_set_text_static(lblSetUseSystemFont, WANT_SYSTEM_FONT);
if (font_time != nullptr) {
lv_font_free(font_time);
}
font_time = &jetbrains_mono_extrabold_compressed;
updateFontTime();
usedSystem = true;
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/WatchFaceStarTrek.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ namespace Pinetime {
int16_t gapy = 0);

lv_font_t* font_time = nullptr;
lv_font_t* font_StarTrek = nullptr;
bool starTrekFontAvailable = false;
void updateFontTime();

Expand Down

0 comments on commit 64283c1

Please sign in to comment.