Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooseremail.cpp
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 134 | } else { | |||
---|---|---|---|---|---|
135 | emit changed(m_currentIndex != index); | 135 | emit changed(m_currentIndex != index); | ||
136 | } | 136 | } | ||
137 | } | 137 | } | ||
138 | 138 | | |||
139 | void CfgEmailClient::save(KConfig *) | 139 | void CfgEmailClient::save(KConfig *) | ||
140 | { | 140 | { | ||
141 | const QString &storageId = currentData().toString(); | 141 | const QString &storageId = currentData().toString(); | ||
142 | const KService::Ptr emailClientService = KService::serviceByStorageId(storageId); | 142 | const KService::Ptr emailClientService = KService::serviceByStorageId(storageId); | ||
143 | if (!emailClientService) { | ||||
144 | // no email client installed or selected | ||||
145 | return; | ||||
146 | } | ||||
143 | 147 | | |||
144 | const bool kmailSelected = m_defaultIndex != -1 && currentIndex() == m_defaultIndex; | 148 | const bool kmailSelected = m_defaultIndex != -1 && currentIndex() == m_defaultIndex; | ||
145 | if (kmailSelected) { | 149 | if (kmailSelected) { | ||
146 | pSettings->setSetting(KEMailSettings::ClientProgram, QString()); | 150 | pSettings->setSetting(KEMailSettings::ClientProgram, QString()); | ||
147 | pSettings->setSetting(KEMailSettings::ClientTerminal, QStringLiteral("false")); | 151 | pSettings->setSetting(KEMailSettings::ClientTerminal, QStringLiteral("false")); | ||
148 | } else { | 152 | } else { | ||
149 | pSettings->setSetting(KEMailSettings::ClientProgram, emailClientService->storageId()); | 153 | pSettings->setSetting(KEMailSettings::ClientProgram, emailClientService->storageId()); | ||
crossi: While you are here, can you had a check on this pointer. I don't understand why there is one… | |||||
I would rather do the opposite the check below is for historical reasons from before my refactoring. meven: I would rather do the opposite the check below is for historical reasons from before my… | |||||
meven: I meant to remove the check below (which I did). | |||||
150 | pSettings->setSetting(KEMailSettings::ClientTerminal, emailClientService->terminal() ? QStringLiteral("true") : QStringLiteral("false")); | 154 | pSettings->setSetting(KEMailSettings::ClientTerminal, emailClientService->terminal() ? QStringLiteral("true") : QStringLiteral("false")); | ||
151 | } | 155 | } | ||
152 | 156 | | |||
153 | // Save the default email client in mimeapps.list | 157 | // Save the default email client in mimeapps.list | ||
154 | KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | 158 | KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | ||
155 | if (profile->isConfigWritable(true) && emailClientService) { | 159 | if (profile->isConfigWritable(true) && emailClientService) { | ||
This actually feels less safe now. What if KService returned a nullptr for some reason? I understand from the logic of early returns you introduced everywhere that you *expect* something. Still I wonder if that's really guaranteed by KService, we could expect bad config somewhere maybe? ervin: This actually feels less safe now. What if KService returned a nullptr for some reason?
I… | |||||
156 | 160 | | |||
157 | KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | 161 | KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | ||
158 | 162 | | |||
159 | // Save the default application according to mime-apps-spec 1.0 | 163 | // Save the default application according to mime-apps-spec 1.0 | ||
160 | KConfigGroup defaultApp(profile, "Default Applications"); | 164 | KConfigGroup defaultApp(profile, "Default Applications"); | ||
161 | defaultApp.writeXdgListEntry(s_mimetype, {emailClientService->storageId()}); | 165 | defaultApp.writeXdgListEntry(s_mimetype, {emailClientService->storageId()}); | ||
162 | 166 | | |||
163 | KConfigGroup addedApps(profile, "Added Associations"); | 167 | KConfigGroup addedApps(profile, "Added Associations"); | ||
Show All 13 Lines |
While you are here, can you had a check on this pointer. I don't understand why there is one below but not here.