Commit f8c5e4d0 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fix crash when using QString as KConfigGroup name, use C Char array from start

Fixes https://bugs.kde.org/show_bug.cgi?id=456157 , seems something goes awry in KConfigGroup's constructor _here_: https://invent.kde.org/frameworks/kconfig/-/blob/master/src/core/kconfiggroup.cpp#L471

Closes kalendar#204



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 85b836c9
Pipeline #211380 passed with stage
in 3 minutes and 40 seconds
......@@ -161,9 +161,14 @@ void KalendarAlarmClient::showIncidence(const QString &uid, const QDateTime &occ
void KalendarAlarmClient::storeNotification(AlarmNotification *notification)
{
// Work around crashing when feeding a QString to the KConfigGroup constructor for the config group name
// BUG: 456157
const auto notificationUidUtf8 = notification->uid().toUtf8();
const auto notificationUidData = notificationUidUtf8.constData();
KConfigGroup suspendedGroup(KSharedConfig::openConfig(), "Suspended");
KConfigGroup notificationGroup(&suspendedGroup, notification->uid());
notificationGroup.writeEntry("UID", notification->uid());
KConfigGroup notificationGroup(&suspendedGroup, notificationUidData);
notificationGroup.writeEntry("UID", notificationUidData);
notificationGroup.writeEntry("Text", notification->text());
if (notification->occurrence().isValid()) {
notificationGroup.writeEntry("Occurrence", notification->occurrence());
......@@ -174,8 +179,13 @@ void KalendarAlarmClient::storeNotification(AlarmNotification *notification)
void KalendarAlarmClient::removeNotification(AlarmNotification *notification)
{
// Work around crashing when feeding a QString to the KConfigGroup constructor for the config group name
// BUG: 456157
const auto notificationUidUtf8 = notification->uid().toUtf8();
const auto notificationUidData = notificationUidUtf8.constData();
KConfigGroup suspendedGroup(KSharedConfig::openConfig(), "Suspended");
KConfigGroup notificationGroup(&suspendedGroup, notification->uid());
KConfigGroup notificationGroup(&suspendedGroup, notificationUidData);
notificationGroup.deleteGroup();
KSharedConfig::openConfig()->sync();
}
......
Supports Markdown
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