mirror of https://github.com/KDE/kasts.git
Fix segmentation fault due to non-existent entry in m_feeds
This commit is contained in:
parent
3a4cdbfec0
commit
056a7b7835
|
@ -20,13 +20,18 @@ DataManager::DataManager()
|
||||||
{
|
{
|
||||||
// connect signals to lambda slots
|
// connect signals to lambda slots
|
||||||
connect(&Fetcher::instance(), &Fetcher::feedDetailsUpdated, this, [this](const QString &url, const QString &name, const QString &image, const QString &link, const QString &description, const QDateTime &lastUpdated) {
|
connect(&Fetcher::instance(), &Fetcher::feedDetailsUpdated, this, [this](const QString &url, const QString &name, const QString &image, const QString &link, const QString &description, const QDateTime &lastUpdated) {
|
||||||
m_feeds[url]->setName(name);
|
qDebug() << "Start updating feed details" << m_feeds;
|
||||||
m_feeds[url]->setImage(image);
|
Feed* feed = getFeed(url);
|
||||||
m_feeds[url]->setLink(link);
|
if (feed != nullptr) {
|
||||||
m_feeds[url]->setDescription(description);
|
feed->setName(name);
|
||||||
m_feeds[url]->setLastUpdated(lastUpdated);
|
feed->setImage(image);
|
||||||
m_feeds[url]->retrieveAuthors();
|
feed->setLink(link);
|
||||||
|
feed->setDescription(description);
|
||||||
|
feed->setLastUpdated(lastUpdated);
|
||||||
|
//qDebug() << "Retrieving authors";
|
||||||
|
feed->retrieveAuthors();
|
||||||
// TODO: signal feedmodel: Q_EMIT dataChanged(createIndex(i, 0), createIndex(i, 0));
|
// TODO: signal feedmodel: Q_EMIT dataChanged(createIndex(i, 0), createIndex(i, 0));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connect(&Fetcher::instance(), &Fetcher::entryAdded, this, [this](const QString &feedurl, const QString &id) {
|
connect(&Fetcher::instance(), &Fetcher::entryAdded, this, [this](const QString &feedurl, const QString &id) {
|
||||||
// Only add the new entry to m_entries
|
// Only add the new entry to m_entries
|
||||||
|
@ -58,6 +63,7 @@ DataManager::DataManager()
|
||||||
Database::instance().execute(query);
|
Database::instance().execute(query);
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
m_feedmap += query.value(QStringLiteral("url")).toString();
|
m_feedmap += query.value(QStringLiteral("url")).toString();
|
||||||
|
m_feeds[query.value(QStringLiteral("url")).toString()] == nullptr;
|
||||||
}
|
}
|
||||||
//qDebug() << m_feedmap;
|
//qDebug() << m_feedmap;
|
||||||
|
|
||||||
|
@ -156,7 +162,7 @@ void DataManager::removeFeed(const Feed* feed)
|
||||||
void DataManager::removeFeed(const int &index)
|
void DataManager::removeFeed(const int &index)
|
||||||
{
|
{
|
||||||
// Get feed pointer
|
// Get feed pointer
|
||||||
Feed* feed = m_feeds[m_feedmap[index]];
|
Feed* feed = getFeed(m_feedmap[index]);
|
||||||
const QString feedurl = feed->url();
|
const QString feedurl = feed->url();
|
||||||
|
|
||||||
// Delete the object instances and mappings
|
// Delete the object instances and mappings
|
||||||
|
@ -240,7 +246,7 @@ void DataManager::addFeed(const QString &url)
|
||||||
query.bindValue(QStringLiteral(":notify"), false);
|
query.bindValue(QStringLiteral(":notify"), false);
|
||||||
Database::instance().execute(query);
|
Database::instance().execute(query);
|
||||||
|
|
||||||
m_feeds[urlFromInput.toString()] = new Feed(urlFromInput.toString());
|
m_feeds[urlFromInput.toString()] = nullptr;
|
||||||
m_feedmap.append(urlFromInput.toString());
|
m_feedmap.append(urlFromInput.toString());
|
||||||
|
|
||||||
Q_EMIT feedAdded(urlFromInput.toString());
|
Q_EMIT feedAdded(urlFromInput.toString());
|
||||||
|
|
Loading…
Reference in New Issue