Verified Commit 359e2cc4 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

EmojiModel: Fix crash in destructor

We can't really know in which order the QmlEngine destroyes the objects, so sometimes the Kaidan::instance() is already deleted when the the EmojiModel destructor is called.
The leads to favourite emojis being lost (oh no) and a segfault.

Fix it by saving when a favourite was added, not when the model is destroyed.
parent 944a1adc
Pipeline #16945 canceled with stages
......@@ -1507,8 +1507,6 @@ EmojiProxyModel::EmojiProxyModel(QObject *parent)
EmojiProxyModel::~EmojiProxyModel()
{
QSettings *settings = Kaidan::instance()->getSettings();
settings->setValue(QLatin1String(FAVORITES_EMOJIS_SETTINGS_PATH), QStringList(m_favoriteEmojis.toList()));
}
Emoji::Group EmojiProxyModel::group() const
......@@ -1553,6 +1551,9 @@ void EmojiProxyModel::addFavoriteEmoji(int proxyRow)
if (m_group == Emoji::Group::Favorites) {
invalidateFilter();
}
QSettings *settings = Kaidan::instance()->getSettings();
settings->setValue(QLatin1String(FAVORITES_EMOJIS_SETTINGS_PATH), QStringList(m_favoriteEmojis.toList()));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment