comparison src/audlegacy/playlist.c @ 4871:985cd1e770df

Fix a crash when deleting a playlist.
author John Lindgren <john.lindgren@tds.net>
date Sun, 26 Apr 2009 03:35:03 -0400
parents f51f043d5e4c
children 9501ad351ac0
comparison
equal deleted inserted replaced
4870:56af01cd5a5c 4871:985cd1e770df
328 328
329 if (active) playlist_select_next(); 329 if (active) playlist_select_next();
330 330
331 /* upon removal, a playlist should be cleared and freed */ 331 /* upon removal, a playlist should be cleared and freed */
332 playlists = g_list_remove(playlists, playlist); 332 playlists = g_list_remove(playlists, playlist);
333 playlist_clear(playlist); 333 playlist_clear_only (playlist);
334 playlist_free(playlist); 334 playlist_free(playlist);
335 335
336 if (playlists_iter == NULL) 336 if (playlists_iter == NULL)
337 playlists_iter = playlists; 337 playlists_iter = playlists;
338 338
898 const DeviceInode *da = a, *db = b; 898 const DeviceInode *da = a, *db = b;
899 return (da->dev == db->dev && da->ino == db->ino); 899 return (da->dev == db->dev && da->ino == db->ino);
900 } 900 }
901 901
902 static gboolean 902 static gboolean
903 devino_destroy(gpointer key, 903 devino_destroy(gpointer key,
904 gpointer value, 904 gpointer value,
905 gpointer data) 905 gpointer data)
906 { 906 {
907 g_free(key); 907 g_free(key);
908 return TRUE; 908 return TRUE;
1013 playlist_add(Playlist * playlist, const gchar * filename) 1013 playlist_add(Playlist * playlist, const gchar * filename)
1014 { 1014 {
1015 return playlist_ins(playlist, filename, -1); 1015 return playlist_ins(playlist, filename, -1);
1016 } 1016 }
1017 1017
1018 guint 1018 guint
1019 playlist_add_dir(Playlist * playlist, const gchar * directory) 1019 playlist_add_dir(Playlist * playlist, const gchar * directory)
1020 { 1020 {
1021 return playlist_ins_dir(playlist, directory, -1, TRUE); 1021 return playlist_ins_dir(playlist, directory, -1, TRUE);
1022 } 1022 }
1023 1023
1500 GList *plist_pos_list; 1500 GList *plist_pos_list;
1501 1501
1502 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) 1502 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong)
1503 ip_data.stop = TRUE; 1503 ip_data.stop = TRUE;
1504 playback_stop(); 1504 playback_stop();
1505 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) 1505 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong)
1506 ip_data.stop = FALSE; 1506 ip_data.stop = FALSE;
1507 1507
1508 hook_call("playback end", playlist->position); 1508 hook_call("playback end", playlist->position);
1509 1509
1510 PLAYLIST_LOCK(playlist); 1510 PLAYLIST_LOCK(playlist);
1931 mtime = tuple_get_int(tuple, FIELD_MTIME, NULL); 1931 mtime = tuple_get_int(tuple, FIELD_MTIME, NULL);
1932 else 1932 else
1933 mtime = 0; 1933 mtime = 0;
1934 1934
1935 // if no tuple or tuple with old mtime, get new one. 1935 // if no tuple or tuple with old mtime, get new one.
1936 if (tuple == NULL || 1936 if (tuple == NULL ||
1937 (entry->tuple && mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename)))) 1937 (entry->tuple && mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename))))
1938 { 1938 {
1939 playlist_entry_get_info(entry); 1939 playlist_entry_get_info(entry);
1940 tuple = entry->tuple; 1940 tuple = entry->tuple;
1941 } 1941 }
2461 { 2461 {
2462 update_playlistwin = TRUE; 2462 update_playlistwin = TRUE;
2463 continue; 2463 continue;
2464 } 2464 }
2465 2465
2466 if (!playlist_entry_get_info(entry) && 2466 if (!playlist_entry_get_info(entry) &&
2467 g_list_index(playlist->entries, entry) == -1) 2467 g_list_index(playlist->entries, entry) == -1)
2468 /* Entry disappeared while we looked it up. 2468 /* Entry disappeared while we looked it up.
2469 Restart. */ 2469 Restart. */
2470 node = playlist->entries; 2470 node = playlist->entries;
2471 else if ((entry->tuple != NULL) || 2471 else if ((entry->tuple != NULL) ||
2472 (entry->title != NULL && 2472 (entry->title != NULL &&
2473 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && 2473 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
2474 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1)) 2474 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1))
2475 { 2475 {
2476 update_playlistwin = TRUE; 2476 update_playlistwin = TRUE;
2477 break; /* hmmm... --asphyx */ 2477 break; /* hmmm... --asphyx */
2584 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock); 2584 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock);
2585 if (!playlist_get_info_going) { 2585 if (!playlist_get_info_going) {
2586 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock); 2586 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
2587 return; 2587 return;
2588 } 2588 }
2589 2589
2590 playlist_get_info_going = FALSE; 2590 playlist_get_info_going = FALSE;
2591 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock); 2591 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
2592 2592
2593 g_cond_broadcast(cond_scan); 2593 g_cond_broadcast(cond_scan);
2594 g_thread_join(playlist_get_info_thread); 2594 g_thread_join(playlist_get_info_thread);
2640 2640
2641 if (!g_str_has_prefix(entry->filename, "file://")) 2641 if (!g_str_has_prefix(entry->filename, "file://"))
2642 continue; 2642 continue;
2643 2643
2644 /* FIXME: Should test for readability */ 2644 /* FIXME: Should test for readability */
2645 if (vfs_file_test(entry->filename, G_FILE_TEST_EXISTS)) 2645 if (vfs_file_test(entry->filename, G_FILE_TEST_EXISTS))
2646 continue; 2646 continue;
2647 2647
2648 if (entry == playlist->position) { 2648 if (entry == playlist->position) {
2649 /* Don't remove the currently playing song */ 2649 /* Don't remove the currently playing song */
2650 if (playback_get_playing()) 2650 if (playback_get_playing())