Code

Bugfix from Niko Tyni, survive select and mouse operations on empty list
authorKalle Wallin <kaw@linux.se>
Sun, 19 Dec 2004 13:08:21 +0000 (13:08 +0000)
committerKalle Wallin <kaw@linux.se>
Sun, 19 Dec 2004 13:08:21 +0000 (13:08 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@2808 09075e82-0dd4-0310-85a5-a0d7c8717e4f

src/screen_file.c

index 75095db9a1bfdbe2e5e9fb9253aba700f7b52a3b..aff58a526e01a0f0ffe66db216d763d053dd9232 100644 (file)
@@ -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 )
     {