Commit cc279b7d authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Fix uninitialized variable warning in konsole_globalaccel.cpp

The compiler may produce a false positive -Wconditional-uninitialized compiler warning.
parent eb834ca2
Pipeline #181385 passed with stage
in 4 minutes and 1 second
......@@ -7,6 +7,8 @@
#include <KGlobalAccel>
#include <KService>
#include <optional>
static void migrateShortcut(const QString &desktopFile, const QList<QKeySequence> &shortcuts)
{
const KService::Ptr service = KService::serviceByStorageId(desktopFile);
......@@ -26,24 +28,22 @@ int main(int argc, char **argv)
KConfig khotkeysrc(QStringLiteral("khotkeysrc"), KConfig::SimpleConfig);
const int dataCount = KConfigGroup(&khotkeysrc, "Data").readEntry("DataCount", 0);
bool foundKmenuedit = false;
int kmenueditIndex;
std::optional<int> kmenueditIndex = std::nullopt;
KConfigGroup kmenueditGroup;
for (int i = 1; i <= dataCount; ++i) {
kmenueditGroup = KConfigGroup(&khotkeysrc, QStringLiteral("Data_%1").arg(i));
if (kmenueditGroup.readEntry("Name") == QLatin1String("KMenuEdit")) {
foundKmenuedit = true;
kmenueditIndex = i;
break;
}
}
if (!foundKmenuedit) {
if (!kmenueditIndex.has_value()) {
return 0;
}
const int shortcutCount = kmenueditGroup.readEntry("DataCount", 0);
for (int i = 1; i <= shortcutCount; ++i) {
const QString groupName = QStringLiteral("Data_%1_%2").arg(kmenueditIndex).arg(i);
const QString groupName = QStringLiteral("Data_%1_%2").arg(kmenueditIndex.value()).arg(i);
if (KConfigGroup(&khotkeysrc, groupName).readEntry("Type") == QLatin1String("MENUENTRY_SHORTCUT_ACTION_DATA")) {
const QString desktopFile = KConfigGroup(&khotkeysrc, groupName + QStringLiteral("Actions0")).readEntry("CommandURL");
if (desktopFile == QLatin1String("org.kde.konsole.desktop")) {
......
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