Skip to content

Commit

Permalink
Fix crash when interacting with empty window
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Apr 11, 2022
1 parent 816432d commit 3886a7e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/wavbreaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,10 @@ static gboolean draw_summary_button_release(GtkWidget *widget,
int x_scale, x_scale_leftover, x_scale_mod;
int leftover_count;

if (!g_sample) {
return TRUE;
}

if (sample_is_playing(g_sample)) {
return TRUE;
}
Expand Down Expand Up @@ -1706,6 +1710,10 @@ void reset_sample_display(guint midpoint)
int width = allocation.width;
int start = midpoint - width / 2;

if (!g_sample) {
return;
}

if (sample_get_num_sample_blocks(g_sample) == 0) {
pixmap_offset = 0;
} else if (width > sample_get_num_sample_blocks(g_sample)) {
Expand Down Expand Up @@ -1824,6 +1832,10 @@ static gboolean button_release(GtkWidget *widget, GdkEventButton *event,
{
gtk_widget_grab_focus(play_button);

if (!g_sample) {
return TRUE;
}

if (event->x + pixmap_offset > sample_get_num_sample_blocks(g_sample)) {
return TRUE;
}
Expand Down

0 comments on commit 3886a7e

Please sign in to comment.