From: Kalle Wallin Date: Sun, 19 Dec 2004 13:08:21 +0000 (+0000) Subject: Bugfix from Niko Tyni, survive select and mouse operations on empty list X-Git-Tag: v0.12_alpha1~447 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3a85ad187b227147ee3f77fc1e204608180ceecd;p=ncmpc.git Bugfix from Niko Tyni, survive select and mouse operations on empty list git-svn-id: https://svn.musicpd.org/ncmpc/trunk@2808 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/src/screen_file.c b/src/screen_file.c index 75095db..aff58a5 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -363,6 +363,8 @@ browse_handle_enter(screen_t *screen, filelist_entry_t *entry; mpd_InfoEntity *entity; + if ( filelist==NULL ) + return -1; entry = ( filelist_entry_t *) g_list_nth_data(filelist->list, lw->selected); if( entry==NULL ) return -1; @@ -442,6 +444,8 @@ browse_handle_select(screen_t *screen, { filelist_entry_t *entry; + if ( filelist==NULL ) + return -1; entry=( filelist_entry_t *) g_list_nth_data(filelist->list, lw->selected); if( entry==NULL || entry->entity==NULL) return -1; @@ -598,12 +602,18 @@ browse_handle_mouse_event(screen_t *screen, int row; int prev_selected = lw->selected; unsigned long bstate; + int length; - if( screen_get_mouse_event(c, lw, filelist->length, &bstate, &row) ) + if ( filelist ) + length = filelist->length; + else + length = 0; + + if( screen_get_mouse_event(c, lw, length, &bstate, &row) ) return 1; lw->selected = lw->start+row; - list_window_check_selected(lw, filelist->length); + list_window_check_selected(lw, length); if( bstate & BUTTON1_CLICKED ) {