Fix crash on startup with Browser as the initial screen
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
* Add support for fetching lyrics from musixmatch.com.
|
* Add support for fetching lyrics from musixmatch.com.
|
||||||
* Fix intermittent failures of the Genius fetcher.
|
* Fix intermittent failures of the Genius fetcher.
|
||||||
* Fix crash on startup with Visualizer as the initial screen.
|
* Fix crash on startup with Visualizer as the initial screen.
|
||||||
|
* Fix crash on startup with Browser as the initial screen.
|
||||||
|
|
||||||
# ncmpcpp-0.9 (2020-12-20)
|
# ncmpcpp-0.9 (2020-12-20)
|
||||||
* Fix various Mopidy specific bugs.
|
* Fix various Mopidy specific bugs.
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ std::vector<MPD::Song> BrowserWindow::getSelectedSongs()
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
Browser::Browser()
|
Browser::Browser()
|
||||||
: m_update_request(true)
|
: m_redraw_header(false)
|
||||||
|
, m_update_request(true)
|
||||||
, m_local_browser(false)
|
, m_local_browser(false)
|
||||||
, m_scroll_beginning(0)
|
, m_scroll_beginning(0)
|
||||||
, m_current_directory("/")
|
, m_current_directory("/")
|
||||||
@@ -165,8 +166,7 @@ void Browser::resize()
|
|||||||
void Browser::switchTo()
|
void Browser::switchTo()
|
||||||
{
|
{
|
||||||
SwitchTo::execute(this);
|
SwitchTo::execute(this);
|
||||||
update();
|
m_redraw_header = true;
|
||||||
drawHeader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Browser::title()
|
std::wstring Browser::title()
|
||||||
@@ -181,7 +181,6 @@ void Browser::update()
|
|||||||
if (m_update_request)
|
if (m_update_request)
|
||||||
{
|
{
|
||||||
m_update_request = false;
|
m_update_request = false;
|
||||||
bool directory_changed = false;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -194,17 +193,17 @@ void Browser::update()
|
|||||||
// If current directory doesn't exist, try getting its
|
// If current directory doesn't exist, try getting its
|
||||||
// parent until we either succeed or reach the root.
|
// parent until we either succeed or reach the root.
|
||||||
if (err.code() == MPD_SERVER_ERROR_NO_EXIST)
|
if (err.code() == MPD_SERVER_ERROR_NO_EXIST)
|
||||||
{
|
|
||||||
m_current_directory = getParentDirectory(m_current_directory);
|
m_current_directory = getParentDirectory(m_current_directory);
|
||||||
directory_changed = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (w.empty() && !inRootDirectory());
|
while (w.empty() && !inRootDirectory());
|
||||||
if (directory_changed)
|
}
|
||||||
drawHeader();
|
if (m_redraw_header)
|
||||||
|
{
|
||||||
|
drawHeader();
|
||||||
|
m_redraw_header = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,10 +431,7 @@ void Browser::locateSong(const MPD::Song &s)
|
|||||||
{
|
{
|
||||||
// Try to change to relevant directory.
|
// Try to change to relevant directory.
|
||||||
if (m_current_directory != s.getDirectory())
|
if (m_current_directory != s.getDirectory())
|
||||||
{
|
|
||||||
getDirectory(s.getDirectory());
|
getDirectory(s.getDirectory());
|
||||||
drawHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Highlight the item.
|
// Highlight the item.
|
||||||
auto begin = w.beginV(), end = w.endV();
|
auto begin = w.beginV(), end = w.endV();
|
||||||
@@ -462,7 +458,6 @@ bool Browser::enterDirectory()
|
|||||||
if (item.type() == MPD::Item::Type::Directory)
|
if (item.type() == MPD::Item::Type::Directory)
|
||||||
{
|
{
|
||||||
getDirectory(item.directory().path());
|
getDirectory(item.directory().path());
|
||||||
drawHeader();
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,7 +474,10 @@ void Browser::getDirectory(std::string directory)
|
|||||||
|
|
||||||
// Reset the position if we change directories.
|
// Reset the position if we change directories.
|
||||||
if (m_current_directory != directory)
|
if (m_current_directory != directory)
|
||||||
|
{
|
||||||
w.reset();
|
w.reset();
|
||||||
|
m_redraw_header = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if it's a parent directory.
|
// Check if it's a parent directory.
|
||||||
if (isStringParentDirectory(directory))
|
if (isStringParentDirectory(directory))
|
||||||
@@ -550,7 +548,6 @@ void Browser::changeBrowseMode()
|
|||||||
m_current_directory = "/";
|
m_current_directory = "/";
|
||||||
w.reset();
|
w.reset();
|
||||||
getDirectory(m_current_directory);
|
getDirectory(m_current_directory);
|
||||||
drawHeader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::remove(const MPD::Item &item)
|
void Browser::remove(const MPD::Item &item)
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ struct Browser: Screen<BrowserWindow>, Filterable, HasSongs, Searchable, Tabbabl
|
|||||||
static void fetchSupportedExtensions();
|
static void fetchSupportedExtensions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_redraw_header;
|
||||||
bool m_update_request;
|
bool m_update_request;
|
||||||
bool m_local_browser;
|
bool m_local_browser;
|
||||||
size_t m_scroll_beginning;
|
size_t m_scroll_beginning;
|
||||||
|
|||||||
Reference in New Issue
Block a user