Skip to content

Commit

Permalink
Memory leak correction
Browse files Browse the repository at this point in the history
  • Loading branch information
plarus committed Dec 30, 2017
1 parent 27ba43a commit 8629ab4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/c/clock_area.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static GFont am_pm_font;
static GRect screen_rect;
#endif

static uint8_t prev_clockFontId;

// "private" functions
static void update_original_clock_area_layer(Layer *l, GContext* ctx, FContext* fctx) {
// check layer bounds
Expand Down Expand Up @@ -287,10 +289,12 @@ void ClockArea_init(Window* window) {
clock_area_layer = layer_create(bounds);
layer_add_child(window_get_root_layer(window), clock_area_layer);
layer_set_update_proc(clock_area_layer, update_clock_area_layer);

prev_clockFontId = FONT_SETTING_UNSET;
}

void ClockArea_ffont_destroy(void) {
switch(globalSettings.prev_clockFontId) {
switch(prev_clockFontId) {
case FONT_SETTING_DEFAULT:
case FONT_SETTING_BOLD:
case FONT_SETTING_LECO:
Expand Down Expand Up @@ -324,8 +328,8 @@ void ClockArea_update_fonts(void) {
}
#endif

if(globalSettings.prev_clockFontId != globalSettings.clockFontId) {
if(globalSettings.prev_clockFontId != FONT_SETTING_UNSET) {
if(prev_clockFontId != globalSettings.clockFontId) {
if(prev_clockFontId != FONT_SETTING_UNSET) {
ClockArea_ffont_destroy();
}

Expand Down Expand Up @@ -372,6 +376,6 @@ void ClockArea_update_fonts(void) {
colon_font = leco;
break;
}
globalSettings.prev_clockFontId = globalSettings.clockFontId;
prev_clockFontId = globalSettings.clockFontId;
}
}
1 change: 0 additions & 1 deletion src/c/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ void Settings_updateDynamicSettings(void) {
globalSettings.enableAutoBatteryWidget = true;
globalSettings.enableBeats = false;
globalSettings.enableAltTimeZone = false;
globalSettings.prev_clockFontId = FONT_SETTING_UNSET;

for(int i = 0; i < 4; i++) {
// if there are any weather widgets, enable weather checking
Expand Down
3 changes: 1 addition & 2 deletions src/c/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ typedef struct {
uint8_t languageId;
bool showLeadingZero;
uint8_t clockFontId;
uint8_t prev_clockFontId;

// vibration settings
bool btVibe;
Expand All @@ -52,7 +51,7 @@ typedef struct {
BarLocationType sidebarLocation;
bool useLargeFonts;
bool activateDisconnectIcon;

// metric or imperial unit
bool useMetric;

Expand Down

0 comments on commit 8629ab4

Please sign in to comment.