Changeset View
Changeset View
Standalone View
Standalone View
src/debugger.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
83 | { | 83 | { | ||
84 | if (supportedBackends().contains(backendName)) { | 84 | if (supportedBackends().contains(backendName)) { | ||
85 | m_backend = backendName; | 85 | m_backend = backendName; | ||
86 | } | 86 | } | ||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | QString Debugger::command() const | 89 | QString Debugger::command() const | ||
90 | { | 90 | { | ||
91 | if (!isValid() || !m_config->hasGroup(m_backend)) { | 91 | return (isValid() && m_config->hasGroup(m_backend)) | ||
92 | return QString(); | 92 | ? m_config->group(m_backend).readPathEntry("Exec", QString()) | ||
93 | } else { | 93 | : QString(); | ||
broulik: I find early returns to be more readable. Maybe just remove the explicit `} else {` statement | |||||
@broulik those changes where made to keep the rest of the file in sync (all of the other functions are using this style) tcanabrava: @broulik those changes where made to keep the rest of the file in sync (all of the other… | |||||
94 | return m_config->group(m_backend).readPathEntry("Exec", QString()); | | |||
95 | } | | |||
96 | } | 94 | } | ||
97 | 95 | | |||
98 | QString Debugger::backtraceBatchCommands() const | 96 | QString Debugger::backtraceBatchCommands() const | ||
99 | { | 97 | { | ||
100 | if (!isValid() || !m_config->hasGroup(m_backend)) { | 98 | return (isValid() && m_config->hasGroup(m_backend)) | ||
101 | return QString(); | 99 | ? m_config->group(m_backend).readPathEntry("BatchCommands", QString()) | ||
102 | } else { | 100 | : QString(); | ||
103 | return m_config->group(m_backend).readEntry("BatchCommands"); | | |||
104 | } | | |||
105 | } | 101 | } | ||
106 | 102 | | |||
107 | bool Debugger::runInTerminal() const | 103 | bool Debugger::runInTerminal() const | ||
108 | { | 104 | { | ||
109 | if (!isValid() || !m_config->hasGroup(m_backend)) { | 105 | return (isValid() && m_config->hasGroup(m_backend)) | ||
110 | return false; | 106 | ? m_config->group(m_backend).readEntry("Terminal", false) | ||
111 | } else { | 107 | : false; | ||
112 | return m_config->group(m_backend).readEntry("Terminal", false); | | |||
113 | } | | |||
114 | } | 108 | } | ||
115 | 109 | | |||
116 | QString Debugger::backendValueOfParameter(const QString &key) const | 110 | QString Debugger::backendValueOfParameter(const QString &key) const | ||
117 | { | 111 | { | ||
118 | if (!isValid() || !m_config->hasGroup(m_backend)) { | 112 | return (isValid() && m_config->hasGroup(m_backend)) | ||
119 | return QString(); | 113 | ? m_config->group(m_backend).readEntry(key, QString()) | ||
120 | } else { | 114 | : QString(); | ||
121 | return m_config->group(m_backend).readEntry(key, QString()); | | |||
122 | } | | |||
123 | } | 115 | } | ||
124 | 116 | | |||
125 | //static | 117 | //static | ||
126 | void Debugger::expandString(QString & str, ExpandStringUsage usage, const QString & tempFile) | 118 | void Debugger::expandString(QString & str, ExpandStringUsage usage, const QString & tempFile) | ||
127 | { | 119 | { | ||
128 | const CrashedApplication *appInfo = DrKonqi::crashedApplication(); | 120 | const CrashedApplication *appInfo = DrKonqi::crashedApplication(); | ||
129 | QHash<QString, QString> map; | 121 | const QHash<QString, QString> map = { | ||
130 | map[QLatin1String("progname")] = appInfo->name(); | 122 | { QLatin1String("progname"), appInfo->name() }, | ||
131 | map[QLatin1String("execname")] = appInfo->fakeExecutableBaseName(); | 123 | { QLatin1String("execname"), appInfo->fakeExecutableBaseName() }, | ||
132 | map[QLatin1String("execpath")] = appInfo->executable().absoluteFilePath(); | 124 | { QLatin1String("execpath"), appInfo->executable().absoluteFilePath() }, | ||
133 | map[QLatin1String("signum")] = QString::number(appInfo->signalNumber()); | 125 | { QLatin1String("signum"), QString::number(appInfo->signalNumber()) }, | ||
134 | map[QLatin1String("signame")] = appInfo->signalName(); | 126 | { QLatin1String("signame"), appInfo->signalName() }, | ||
135 | map[QLatin1String("pid")] = QString::number(appInfo->pid()); | 127 | { QLatin1String("pid"), QString::number(appInfo->pid()) }, | ||
136 | map[QLatin1String("tempfile")] = tempFile; | 128 | { QLatin1String("tempfile"), tempFile }, | ||
137 | map[QLatin1String("thread")] = QString::number(appInfo->thread()); | 129 | { QLatin1String("thread"), QString::number(appInfo->thread()) }, | ||
130 | }; | ||||
138 | 131 | | |||
139 | if (usage == ExpansionUsageShell) { | 132 | if (usage == ExpansionUsageShell) { | ||
140 | str = KMacroExpander::expandMacrosShellQuote(str, map); | 133 | str = KMacroExpander::expandMacrosShellQuote(str, map); | ||
141 | } else { | 134 | } else { | ||
142 | str = KMacroExpander::expandMacros(str, map); | 135 | str = KMacroExpander::expandMacros(str, map); | ||
143 | } | 136 | } | ||
144 | } | 137 | } | ||
145 | 138 | | |||
Show All 24 Lines |
I find early returns to be more readable. Maybe just remove the explicit } else { statement