diff --git a/src/data.c b/src/data.c index 91c1e59..cf5643a 100644 --- a/src/data.c +++ b/src/data.c @@ -45,6 +45,7 @@ GList *data_get_manga(void) } else g_print("error %d: %s\n", res, sqlite3_errmsg(database)); + /* Release the compiled statement from memory */ sqlite3_finalize(statement); } @@ -80,6 +81,7 @@ Manga *data_get_manga_by_id(gint manga_id) manga = data_get_manga_from_statement(statement); } } + sqlite3_finalize(statement); } sqlite3_close(database); @@ -107,31 +109,31 @@ void data_get_volumes_by_manga_id(gint manga_id, gint *size, gint **vols) " FROM volume " " WHERE manga_id = %d ", manga_id); - g_print("%s\n", sql); res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL); if (res == SQLITE_OK) { if (sqlite3_step(statement) == SQLITE_ROW) { count = sqlite3_column_int(statement, 0); } } + sqlite3_finalize(statement); - g_print("%d: %d\n", manga_id, count); if (count > 0) { sql = g_strdup_printf( " SELECT id " " FROM volume " " WHERE manga_id = %d ", manga_id); - g_print("%s\n", sql); + res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL); if (res == SQLITE_OK) { gint i = 0; while (sqlite3_step(statement) == SQLITE_ROW) { gint volume = sqlite3_column_int(statement, 0); - g_print("volume: %d\n", volume); volumes[i++] = volume; } } + + sqlite3_finalize(statement); } } sqlite3_close(database); @@ -166,6 +168,7 @@ gboolean data_add_manga(gchar *name, gint total_qty) if (sqlite3_step(statement) == SQLITE_DONE) result = TRUE; } + sqlite3_finalize(statement); } sqlite3_close(database); @@ -200,6 +203,7 @@ gboolean data_add_to_manga(gint manga_id, gint count) if (sqlite3_step(statement) == SQLITE_DONE) result = TRUE; } + sqlite3_finalize(statement); } sqlite3_close(database); @@ -238,6 +242,7 @@ gboolean data_add_volume_to_manga(gint manga_id, gint volume) } else g_print("res was not OK\n"); + sqlite3_finalize(statement); } else @@ -279,6 +284,7 @@ gboolean data_remove_volume_from_manga(gint manga_id, gint volume) g_print("step did not return DONE\n"); else g_print("result did not return OK\n"); + sqlite3_finalize(statement); } else diff --git a/src/eom-edit-window.c b/src/eom-edit-window.c index aa8e72b..80a6c55 100644 --- a/src/eom-edit-window.c +++ b/src/eom-edit-window.c @@ -58,6 +58,15 @@ static void eom_edit_window_get_property(GObject *object, } } +static void eom_edit_window_finalize(GObject *object) +{ + EomEditWindow *self = EOM_EDIT_WINDOW(object); + + g_free(self->current_manga); + + G_OBJECT_CLASS(eom_edit_window_parent_class)->finalize(object); +} + static void eom_edit_window_class_init(EomEditWindowClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); @@ -65,6 +74,7 @@ static void eom_edit_window_class_init(EomEditWindowClass *klass) gobject_class->set_property = eom_edit_window_set_property; gobject_class->get_property = eom_edit_window_get_property; + gobject_class->finalize = eom_edit_window_finalize; pspec = g_param_spec_int("manga-id", "ID of the manga", @@ -157,7 +167,6 @@ static void eom_edit_window_set_manga_id(EomEditWindow *self, button = gtk_toggle_button_new_with_label(g_strdup_printf("%d", i + 1)); gtk_box_pack_start(GTK_BOX(self->volumes_box), button, TRUE, TRUE, 0); - g_print("volume found: %d, i=%d\n", volumes[j], i); if (j < num_vols && volumes[j] == i+1) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); j++; @@ -180,15 +189,11 @@ static void eom_edit_window_on_volume_toggled(GtkToggleButton *togglebutton, active = gtk_toggle_button_get_active(togglebutton); volume = atoi(gtk_button_get_label(GTK_BUTTON(togglebutton))); - g_print("toggled %d: %d\n", self->current_manga->id, volume); - if (active) { if (!data_add_to_manga(self->current_manga->id, 1)) { - g_print("not added 1 volume to %d\n", self->current_manga->id); return; } if (!data_add_volume_to_manga(self->current_manga->id, volume)) { - g_print("not added volume %d to %d\n", volume, self->current_manga->id); data_add_to_manga(self->current_manga->id, 1); return; } @@ -196,11 +201,9 @@ static void eom_edit_window_on_volume_toggled(GtkToggleButton *togglebutton, } else { if (!data_add_to_manga(self->current_manga->id, -1)) { - g_print("not added -1 volumes to %d\n", self->current_manga->id); return; } if (!data_remove_volume_from_manga(self->current_manga->id, volume)) { - g_print("not added volume %d to %d\n", volume, self->current_manga->id); data_add_to_manga(self->current_manga->id, 1); /* Undo */ return; } diff --git a/src/eom-main-window.c b/src/eom-main-window.c index d17604c..6c70150 100644 --- a/src/eom-main-window.c +++ b/src/eom-main-window.c @@ -48,6 +48,9 @@ void eom_main_window_load(EomMainWindow *self) Manga *manga = list->data; eom_main_window_add_line(self, manga->id, manga->name, manga->current_qty, manga->total_qty); + + free(manga->name); + free(manga); list = g_list_next(list); }