From b1bb7ec295373a941cc1dba103d93605602ec962 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 16 Aug 2010 14:13:24 +0200 Subject: [PATCH] ncmpcpp: check for list emptiness before taking current element from it --- src/ncmpcpp.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 2423ff3f..0c3b7113 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1539,7 +1539,9 @@ int main(int argc, char *argv[]) } } } - else if (myScreen->ActiveWindow() == myTagEditor->Dirs) + else if (myScreen->ActiveWindow() == myTagEditor->Dirs + && !myTagEditor->Dirs->Empty() + && myTagEditor->Dirs->Choice() > 0) { std::string old_dir = myTagEditor->Dirs->Current().first; LockStatusbar(); @@ -1569,7 +1571,7 @@ int main(int argc, char *argv[]) { myLyrics->Edit(); } - if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory) + if (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->Main()->Current().type == itDirectory) { std::string old_dir = myBrowser->Main()->Current().name; LockStatusbar(); @@ -1602,7 +1604,15 @@ int main(int argc, char *argv[]) } } } - else if (myScreen->ActiveWindow() == myPlaylistEditor->Playlists || (myScreen == myBrowser && myBrowser->Main()->Current().type == itPlaylist)) + else if ( + (myScreen->ActiveWindow() == myPlaylistEditor->Playlists + && !myPlaylistEditor->Playlists->Empty() + ) + || (myScreen == myBrowser + && !myBrowser->Main()->Empty() + && myBrowser->Main()->Current().type == itPlaylist + ) + ) { std::string old_name = myScreen->ActiveWindow() == myPlaylistEditor->Playlists ? myPlaylistEditor->Playlists->Current() : myBrowser->Main()->Current().name; LockStatusbar();