Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
5.2
Browse files Browse the repository at this point in the history
Fix leak on memory usage
  • Loading branch information
dieghernan committed Apr 17, 2017
1 parent 3550475 commit 6e6e509
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 62 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"resources": {
"media": [
{
"characterRegex": "[a-z]",
"file": "fonts/ConsSymb.ttf",
"name": "FONT_SYMBOL_16",
"file": "images/menu_icon_spanish_text_watch.png",
"menuIcon": true,
"name": "iconmenu",
"targetPlatforms": null,
"type": "font"
"type": "bitmap"
},
{
"file": "fonts/weatherfontcustom2.ttf",
Expand All @@ -49,16 +49,15 @@
"type": "font"
},
{
"file": "images/menu_icon_spanish_text_watch.png",
"menuIcon": true,
"name": "iconmenu",
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_16",
"targetPlatforms": null,
"type": "bitmap"
"type": "font"
},
{
"characterRegex": "[a-z' UV\u00f6\u00fc]",
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_30",
"name": "FONT_GLIGHT_39",
"targetPlatforms": null,
"trackingAdjust": -2,
"type": "font"
Expand All @@ -74,21 +73,21 @@
{
"characterRegex": "[a-z' UV\u00f6\u00fc]",
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_39",
"name": "FONT_GLIGHT_30",
"targetPlatforms": null,
"trackingAdjust": -2,
"type": "font"
},
{
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_16",
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_16",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[a-z' UV\u00f6\u00fc]",
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_30",
"name": "FONT_GBOLD_39",
"targetPlatforms": null,
"trackingAdjust": -1,
"type": "font"
Expand All @@ -104,14 +103,15 @@
{
"characterRegex": "[a-z' UV\u00f6\u00fc]",
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_39",
"name": "FONT_GBOLD_30",
"targetPlatforms": null,
"trackingAdjust": -1,
"type": "font"
},
{
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_16",
"characterRegex": "[a-z]",
"file": "fonts/ConsSymb.ttf",
"name": "FONT_SYMBOL_16",
"targetPlatforms": null,
"type": "font"
}
Expand All @@ -129,5 +129,5 @@
"watchface": true
}
},
"version": "5.1.0"
"version": "5.2.0"
}
108 changes: 63 additions & 45 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,44 +828,30 @@ static void prv_window_load(Window *window) {
}
// Window Unload event
static void prv_window_unload(Window *window) {
layer_destroy(back_layer);
layer_destroy(back_layer);
window_destroy(s_main_window);
text_layer_destroy(line1.currentLayer);
text_layer_destroy(line1.nextLayer);
text_layer_destroy(line2.currentLayer);
text_layer_destroy(line2.nextLayer);
text_layer_destroy(line3.currentLayer);
text_layer_destroy(line3.nextLayer);
layer_destroy(scroll);
fonts_unload_custom_font(FontCond);
fonts_unload_custom_font(Bold);
fonts_unload_custom_font(BoldReduced1);
fonts_unload_custom_font(BoldReduced2);
fonts_unload_custom_font(Light);
fonts_unload_custom_font(LightReduced1);
fonts_unload_custom_font(LightReduced2);
fonts_unload_custom_font(FontWDay);
fonts_unload_custom_font(FontDate);
fonts_unload_custom_font(FontSymbol);
}
static void prv_init(void) {
prv_load_settings();

//Starting loop at 0
s_loop=0;
s_countdown=settings.UpSlider;
//Clean vars
strcpy(tempstring, "");
strcpy(condstringday, "");
strcpy(condstringnight, "");


// Listen for AppMessages
app_message_register_inbox_received(prv_inbox_received_handler);
app_message_open(256, 256);

// Configure main window
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});
void main_window_push() {
s_main_window = window_create();

// Load fonts
Bold=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_39));
BoldReduced1=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_34));
BoldReduced2=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_30));
Light=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_39));
LightReduced1=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_34));
LightReduced2=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_30));
FontCond=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_WICON_26));
FontWDay=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_16));
FontDate=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_16));
FontSymbol =fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_16));

window_stack_push(s_main_window, true);
Layer *root = window_get_root_layer(s_main_window);

//Set bounds and offsets
Expand Down Expand Up @@ -898,9 +884,48 @@ static void prv_init(void) {
layer_add_child(scroll, (Layer *)line2.nextLayer);
layer_add_child(scroll, (Layer *)line3.currentLayer);
layer_add_child(scroll, (Layer *)line3.nextLayer);


// Configure main window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});


window_stack_push(s_main_window, true);
}


static void prv_init(void) {
prv_load_settings();

//Starting loop at 0
s_loop=0;
s_countdown=settings.UpSlider;
//Clean vars
strcpy(tempstring, "");
strcpy(condstringday, "");
strcpy(condstringnight, "");


// Listen for AppMessages
app_message_register_inbox_received(prv_inbox_received_handler);
app_message_open(256, 256);

// Load fonts
Bold=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_39));
BoldReduced1=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_34));
BoldReduced2=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_30));
Light=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_39));
LightReduced1=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_34));
LightReduced2=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_30));
FontCond=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_WICON_26));
FontWDay=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GBOLD_16));
FontDate=fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GLIGHT_16));
FontSymbol =fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_16));

main_window_push();

// Configure text time on init
time_t now = time(NULL);
struct tm *t = localtime(&now);
Expand Down Expand Up @@ -935,16 +960,9 @@ static void prv_init(void) {
}
}
static void prv_deinit(void) {
window_destroy(s_main_window);

tick_timer_service_unsubscribe();
app_message_deregister_callbacks(); //Destroy the callbacks for clean up
text_layer_destroy(line1.currentLayer);
text_layer_destroy(line1.nextLayer);
text_layer_destroy(line2.currentLayer);
text_layer_destroy(line2.nextLayer);
text_layer_destroy(line3.currentLayer);
text_layer_destroy(line3.nextLayer);
layer_destroy(scroll);
app_message_deregister_callbacks(); //Destroy the callbacks for clean up
}
int main(void) {
prv_init();
Expand Down

0 comments on commit 6e6e509

Please sign in to comment.