Skip to content

Commit

Permalink
fix(application): properly save output file upon clean exit
Browse files Browse the repository at this point in the history
The bug was introduced by `f3e5d86`.

Closes #8
  • Loading branch information
jtheoof committed Feb 21, 2020
1 parent 320dae0 commit b5cc433
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ static void save_state_to_file_or_folder(struct swappy_state *state,
g_object_unref(pixbuf);
}

void on_destroy(GtkApplication *application, gpointer data) {
struct swappy_state *state = (struct swappy_state *)data;
static void maybe_save_output_file(struct swappy_state *state) {
if (state->output_file != NULL) {
save_state_to_file_or_folder(state, state->output_file);
}
}

void on_destroy(GtkApplication *application, gpointer data) {
struct swappy_state *state = (struct swappy_state *)data;
maybe_save_output_file(state);
}

void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
switch_mode_to_brush(state);
}
Expand Down Expand Up @@ -267,6 +271,7 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event,
switch (event->keyval) {
case GDK_KEY_Escape:
case GDK_KEY_q:
maybe_save_output_file(state);
gtk_main_quit();
break;
case GDK_KEY_b:
Expand Down

0 comments on commit b5cc433

Please sign in to comment.