Fix crashes when invoking DB query functions with invalid index
This commit is contained in:
parent
63f0ab96a4
commit
5222082635
|
@ -43,7 +43,7 @@ LyricsWikiaResultsModel::LyricsWikiaResultsModel(SongDescription &&initialSongDe
|
|||
|
||||
bool LyricsWikiaResultsModel::fetchCover(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= m_results.size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ bool LyricsWikiaResultsModel::fetchCover(const QModelIndex &index)
|
|||
|
||||
bool LyricsWikiaResultsModel::fetchLyrics(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= m_results.size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ void LyricsWikiaResultsModel::parseAlbumDetailsAndFetchCover(int row, const QByt
|
|||
|
||||
QUrl LyricsWikiaResultsModel::webUrl(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= results().size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ MusicBrainzResultsModel::MusicBrainzResultsModel(SongDescription &&initialSongDe
|
|||
|
||||
bool MusicBrainzResultsModel::fetchCover(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= m_results.size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,10 @@ bool MusicBrainzResultsModel::fetchCover(const QModelIndex &index)
|
|||
|
||||
QUrl MusicBrainzResultsModel::webUrl(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= results().size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return QUrl();
|
||||
}
|
||||
return QUrl(QStringLiteral("https://musicbrainz.org/recording/") + results().at(index.row()).songId);
|
||||
return QUrl(QStringLiteral("https://musicbrainz.org/recording/") + m_results.at(index.row()).songId);
|
||||
}
|
||||
|
||||
void MusicBrainzResultsModel::parseInitialResults(const QByteArray &data)
|
||||
|
|
|
@ -32,7 +32,7 @@ TekstowoResultsModel::TekstowoResultsModel(SongDescription &&initialSongDescript
|
|||
|
||||
bool TekstowoResultsModel::fetchLyrics(const QModelIndex &index)
|
||||
{
|
||||
if ((index.parent().isValid() || index.row() >= m_results.size()) && !m_results[index.row()].lyrics.isEmpty()) {
|
||||
if ((index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) || m_results[index.row()].lyrics.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
const auto url = webUrl(index);
|
||||
|
@ -145,7 +145,7 @@ void TekstowoResultsModel::parseLyricsResults(int row, const QByteArray &data)
|
|||
|
||||
QUrl TekstowoResultsModel::webUrl(const QModelIndex &index)
|
||||
{
|
||||
if (index.parent().isValid() || index.row() >= results().size()) {
|
||||
if (index.parent().isValid() || !index.isValid() || index.row() >= m_results.size()) {
|
||||
return QUrl();
|
||||
}
|
||||
auto url = tekstowoUrl();
|
||||
|
|
Loading…
Reference in New Issue