Fix segfault when trying to remove a non-subscribed podcast

BUG: 471107
This commit is contained in:
Bart De Vries 2023-06-18 15:12:59 +02:00
parent cf274a7aca
commit b529bfc3ca
1 changed files with 84 additions and 75 deletions

View File

@ -207,14 +207,19 @@ void DataManager::removeFeed(const int index)
{ {
// Get feed pointer // Get feed pointer
Feed *feed = getFeed(m_feedmap[index]); Feed *feed = getFeed(m_feedmap[index]);
if (feed) {
removeFeed(feed); removeFeed(feed);
}
} }
void DataManager::removeFeeds(const QStringList &feedurls) void DataManager::removeFeeds(const QStringList &feedurls)
{ {
QList<Feed *> feeds; QList<Feed *> feeds;
for (QString feedurl : feedurls) { for (QString feedurl : feedurls) {
feeds << getFeed(feedurl); Feed *feed = getFeed(feedurl);
if (feed) {
feeds << feed;
}
} }
removeFeeds(feeds); removeFeeds(feeds);
} }
@ -224,15 +229,18 @@ void DataManager::removeFeeds(const QVariantList feedVariantList)
QList<Feed *> feeds; QList<Feed *> feeds;
for (QVariant feedVariant : feedVariantList) { for (QVariant feedVariant : feedVariantList) {
if (feedVariant.canConvert<Feed *>()) { if (feedVariant.canConvert<Feed *>()) {
if (feedVariant.value<Feed *>()) {
feeds << feedVariant.value<Feed *>(); feeds << feedVariant.value<Feed *>();
} }
} }
}
removeFeeds(feeds); removeFeeds(feeds);
} }
void DataManager::removeFeeds(const QList<Feed *> &feeds) void DataManager::removeFeeds(const QList<Feed *> &feeds)
{ {
for (Feed *feed : feeds) { for (Feed *feed : feeds) {
if (feed) {
const QString feedurl = feed->url(); const QString feedurl = feed->url();
int index = m_feedmap.indexOf(feedurl); int index = m_feedmap.indexOf(feedurl);
@ -311,6 +319,7 @@ void DataManager::removeFeeds(const QList<Feed *> &feeds)
Q_EMIT feedRemoved(index); Q_EMIT feedRemoved(index);
} }
}
// if settings allow, then upload these changes immediately to sync server // if settings allow, then upload these changes immediately to sync server
Sync::instance().doQuickSync(); Sync::instance().doQuickSync();