diff --git a/src/backtraceratingwidget.h b/src/backtraceratingwidget.h
--- a/src/backtraceratingwidget.h
+++ b/src/backtraceratingwidget.h
@@ -47,10 +47,7 @@
BacktraceGenerator::State m_state;
- bool m_star1;
- bool m_star2;
- bool m_star3;
-
+ int m_numStars;
QPixmap m_errorPixmap;
QPixmap m_starPixmap;
diff --git a/src/backtraceratingwidget.cpp b/src/backtraceratingwidget.cpp
--- a/src/backtraceratingwidget.cpp
+++ b/src/backtraceratingwidget.cpp
@@ -24,10 +24,7 @@
BacktraceRatingWidget::BacktraceRatingWidget(QWidget * parent) :
QWidget(parent),
- m_state(BacktraceGenerator::NotLoaded),
- m_star1(false),
- m_star2(false),
- m_star3(false)
+ m_state(BacktraceGenerator::NotLoaded)
{
setMinimumSize(105, 24);
@@ -38,55 +35,39 @@
void BacktraceRatingWidget::setUsefulness(BacktraceParser::Usefulness usefulness)
{
- switch (usefulness) {
- case BacktraceParser::ReallyUseful: {
- m_star1 = true;
- m_star2 = true;
- m_star3 = true;
+ switch(usefulness) {
+ case BacktraceParser::ReallyUseful:
+ m_numStars = 3;
break;
- }
- case BacktraceParser::MayBeUseful: {
- m_star1 = true;
- m_star2 = true;
- m_star3 = false;
+ case BacktraceParser::MayBeUseful:
+ m_numStars = 2;
break;
- }
- case BacktraceParser::ProbablyUseless: {
- m_star1 = true;
- m_star2 = false;
- m_star3 = false;
+ case BacktraceParser::ProbablyUseless:
+ m_numStars = 1;
break;
- }
- case BacktraceParser::Useless:
- case BacktraceParser::InvalidUsefulness: {
- m_star1 = false;
- m_star2 = false;
- m_star3 = false;
+ case BacktraceParser::Useless:
+ case BacktraceParser::InvalidUsefulness:
+ m_numStars = 0;
break;
}
- }
-
update();
}
void BacktraceRatingWidget::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPainter p(this);
-
- p.drawPixmap(QPoint(30, 1) , m_star1 ? m_starPixmap : m_disabledStarPixmap);
- p.drawPixmap(QPoint(55, 1) , m_star2 ? m_starPixmap : m_disabledStarPixmap);
- p.drawPixmap(QPoint(80, 1) , m_star3 ? m_starPixmap : m_disabledStarPixmap);
+ p.drawPixmap(QPoint(30, 1) , m_numStars >= 1 ? m_starPixmap : m_disabledStarPixmap);
+ p.drawPixmap(QPoint(55, 1) , m_numStars >= 2 ? m_starPixmap : m_disabledStarPixmap);
+ p.drawPixmap(QPoint(80, 1) , m_numStars >= 3 ? m_starPixmap : m_disabledStarPixmap);
switch (m_state) {
case BacktraceGenerator::Failed:
case BacktraceGenerator::FailedToStart: {
p.drawPixmap(QPoint(0, 1) , m_errorPixmap);
break;
}
- case BacktraceGenerator::Loading:
- case BacktraceGenerator::Loaded:
default:
break;
}
diff --git a/src/backtracewidget.cpp b/src/backtracewidget.cpp
--- a/src/backtracewidget.cpp
+++ b/src/backtracewidget.cpp
@@ -339,15 +339,13 @@
void BacktraceWidget::hilightExtraDetailsLabel(bool hilight)
{
- QString stylesheet;
- if (hilight) {
- stylesheet = QLatin1String("border-width: 2px; "
- "border-style: solid; "
- "border-color: red;");
- } else {
- stylesheet = QLatin1String("border-width: 0px;");
- }
- stylesheet += QLatin1String(extraDetailsLabelMargin);
+ const QString stylesheet = ((!hilight)
+ ? QLatin1String("border-width: 0px;")
+ : QLatin1String("border-width: 2px; "
+ "border-style: solid; "
+ "border-color: red;"))
+ + QLatin1String(extraDetailsLabelMargin);
+
ui.m_extraDetailsLabel->setStyleSheet(stylesheet);
}
@@ -396,9 +394,9 @@
missingDbgForFiles.insert(0, DrKonqi::crashedApplication()->executable().absoluteFilePath());
//HTML message
- QString message = QStringLiteral("");
- message += i18n("The packages containing debug information for the following application and libraries are missing:");
- message += QStringLiteral("
");
+ QString message = QStringLiteral("")
+ + i18n("The packages containing debug information for the following application and libraries are missing:")
+ + QStringLiteral("
");
Q_FOREACH(const QString & string, missingDbgForFiles) {
message += QStringLiteral("- ") + string + QStringLiteral("
");
diff --git a/src/crashedapplication.cpp b/src/crashedapplication.cpp
--- a/src/crashedapplication.cpp
+++ b/src/crashedapplication.cpp
@@ -152,18 +152,11 @@
return;
}
- int ret = -1;
-
//start the application via kdeinit, as it needs to have a pristine environment and
//KProcess::startDetached() can't start a new process with custom environment variables.
- if (!m_fakeBaseName.isEmpty()) {
- // if m_fakeBaseName is set, this means m_executable is the path to kdeinit4
- // so we need to use the fakeBaseName to restart the app
- ret = KToolInvocation::kdeinitExec(m_fakeBaseName);
- } else {
- ret = KToolInvocation::kdeinitExec(m_executable.absoluteFilePath());
- }
-
+ // if m_fakeBaseName is set, this means m_executable is the path to kdeinit4
+ // so we need to use the fakeBaseName to restart the app
+ const int ret = KToolInvocation::kdeinitExec(!m_fakeBaseName.isEmpty() ? m_fakeBaseName : m_executable.absoluteFilePath());
const bool success = (ret == 0);
m_restarted = success;
diff --git a/src/debugger.cpp b/src/debugger.cpp
--- a/src/debugger.cpp
+++ b/src/debugger.cpp
@@ -88,53 +88,46 @@
QString Debugger::command() const
{
- if (!isValid() || !m_config->hasGroup(m_backend)) {
- return QString();
- } else {
- return m_config->group(m_backend).readPathEntry("Exec", QString());
- }
+ return (isValid() && m_config->hasGroup(m_backend))
+ ? m_config->group(m_backend).readPathEntry("Exec", QString())
+ : QString();
}
QString Debugger::backtraceBatchCommands() const
{
- if (!isValid() || !m_config->hasGroup(m_backend)) {
- return QString();
- } else {
- return m_config->group(m_backend).readEntry("BatchCommands");
- }
+ return (isValid() && m_config->hasGroup(m_backend))
+ ? m_config->group(m_backend).readPathEntry("BatchCommands", QString())
+ : QString();
}
bool Debugger::runInTerminal() const
{
- if (!isValid() || !m_config->hasGroup(m_backend)) {
- return false;
- } else {
- return m_config->group(m_backend).readEntry("Terminal", false);
- }
+ return (isValid() && m_config->hasGroup(m_backend))
+ ? m_config->group(m_backend).readEntry("Terminal", false)
+ : false;
}
QString Debugger::backendValueOfParameter(const QString &key) const
{
- if (!isValid() || !m_config->hasGroup(m_backend)) {
- return QString();
- } else {
- return m_config->group(m_backend).readEntry(key, QString());
- }
+ return (isValid() && m_config->hasGroup(m_backend))
+ ? m_config->group(m_backend).readEntry(key, QString())
+ : QString();
}
//static
void Debugger::expandString(QString & str, ExpandStringUsage usage, const QString & tempFile)
{
const CrashedApplication *appInfo = DrKonqi::crashedApplication();
- QHash map;
- map[QLatin1String("progname")] = appInfo->name();
- map[QLatin1String("execname")] = appInfo->fakeExecutableBaseName();
- map[QLatin1String("execpath")] = appInfo->executable().absoluteFilePath();
- map[QLatin1String("signum")] = QString::number(appInfo->signalNumber());
- map[QLatin1String("signame")] = appInfo->signalName();
- map[QLatin1String("pid")] = QString::number(appInfo->pid());
- map[QLatin1String("tempfile")] = tempFile;
- map[QLatin1String("thread")] = QString::number(appInfo->thread());
+ const QHash map = {
+ { QLatin1String("progname"), appInfo->name() },
+ { QLatin1String("execname"), appInfo->fakeExecutableBaseName() },
+ { QLatin1String("execpath"), appInfo->executable().absoluteFilePath() },
+ { QLatin1String("signum"), QString::number(appInfo->signalNumber()) },
+ { QLatin1String("signame"), appInfo->signalName() },
+ { QLatin1String("pid"), QString::number(appInfo->pid()) },
+ { QLatin1String("tempfile"), tempFile },
+ { QLatin1String("thread"), QString::number(appInfo->thread()) },
+ };
if (usage == ExpansionUsageShell) {
str = KMacroExpander::expandMacrosShellQuote(str, map);
diff --git a/src/drkonqi.h b/src/drkonqi.h
--- a/src/drkonqi.h
+++ b/src/drkonqi.h
@@ -30,7 +30,6 @@
{
public:
static bool init();
- static void cleanup();
static SystemInformation *systemInformation();
static DebuggerManager *debuggerManager();
diff --git a/src/drkonqi.cpp b/src/drkonqi.cpp
--- a/src/drkonqi.cpp
+++ b/src/drkonqi.cpp
@@ -81,11 +81,8 @@
//static
DrKonqi *DrKonqi::instance()
{
- static DrKonqi *drKonqiInstance = nullptr;
- if (!drKonqiInstance) {
- drKonqiInstance = new DrKonqi();
- }
- return drKonqiInstance;
+ static DrKonqi drKonqiInstance;
+ return &drKonqiInstance;
}
//based on KCrashDelaySetHandler from kdeui/util/kcrash.cpp
@@ -107,7 +104,6 @@
bool DrKonqi::init()
{
if (!instance()->m_backend->init()) {
- cleanup();
return false;
} else { //all ok, continue initialization
// Set drkonqi to handle its own crashes, but only if the crashed app
@@ -123,11 +119,6 @@
}
}
-void DrKonqi::cleanup()
-{
- delete instance();
-}
-
//static
SystemInformation *DrKonqi::systemInformation()
{
diff --git a/src/findconfigdatajob.h b/src/findconfigdatajob.h
deleted file mode 100644
--- a/src/findconfigdatajob.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************
-* findconfigdatajob.h
-* Copyright 2011 Matthias Fuchs
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-******************************************************************/
-
-#ifndef DRKONQI_FIND_VERSIONS_JOB_H
-#define DRKONQI_FIND_VERSIONS_JOB_H
-
-#include
-
-#include
-#include
-
-namespace KIO {
- class StoredTransferJob;
-}
-
-/**
- * This job downloads config.cgi for a specified product,
- * looking for the information you want to retrieve
- */
-class FindConfigDataJob : public KJob
-{
- Q_OBJECT
- public:
- /**
- * @param productName e.g. "plasma"
- * @param bugtrackerBaseUrl e.g. "https://bugs.kde.org"
- */
- explicit FindConfigDataJob(const QString &productName, const QUrl &bugtrackerBaseUrl, QObject *parent = nullptr);
- virtual ~FindConfigDataJob();
-
- virtual void start();
- virtual QString errorString() const;
-
- enum InformationType {
- Version
- };
-
- /**
- * Call this after the job finished to retrieve the
- * specified data
- */
- QStringList data(InformationType type);
-
- private Q_SLOTS:
- void receivedData(KJob *job);
-
- private:
- KIO::StoredTransferJob *m_job = nullptr;
- QUrl m_url;
- QString m_data;
- QString m_errorString;
-};
-
-#endif
diff --git a/src/findconfigdatajob.cpp b/src/findconfigdatajob.cpp
deleted file mode 100644
--- a/src/findconfigdatajob.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************
-* findconfigdatajob.cpp
-* Copyright 2011 Matthias Fuchs
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-******************************************************************/
-
-#include "findconfigdatajob.h"
-
-#include
-#include
-
-FindConfigDataJob::FindConfigDataJob(const QString &productName, const QUrl &bugtrackerBaseUrl, QObject *parent)
- : KJob(parent),
- m_job(0),
- m_url(bugtrackerBaseUrl)
-{
- m_url.addPath("config.cgi");
- m_url.addQueryItem("product", productName);
-}
-
-FindConfigDataJob::~FindConfigDataJob()
-{
- if (m_job) {
- m_job->kill();
- }
-}
-
-void FindConfigDataJob::start()
-{
- m_job = KIO::storedGet(m_url, KIO::Reload, KIO::HideProgressInfo);
- connect(m_job, &KIO::StoredTransferJob::result, this, &FindConfigDataJob::receivedData);
- connect(m_job, &KIO::StoredTransferJob::infoMessage, this, &FindConfigDataJob::infoMessage);
- connect(m_job, &KIO::StoredTransferJob::warning, this, &FindConfigDataJob::warning);
-
- m_job->start();
-}
-
-QString FindConfigDataJob::errorString() const
-{
- return m_errorString;
-}
-
-void FindConfigDataJob::receivedData(KJob *job)
-{
- Q_UNUSED(job);
-
- if (m_job->error()) {
- setError(m_job->error());
- m_errorString = i18n("Failed to retrieve the config data.");
- } else {
- m_data = m_job->data();
- }
- m_job = 0;
- emitResult();
-}
-
-QStringList FindConfigDataJob::data(InformationType type)
-{
- QStringList result;
- QString key;
-
- switch (type) {
- case Version:
- key = "version\\['[^\']+'\\]";
- break;
- default:
- Q_ASSERT(false);
- break;
- }
-
- QRegExp rx(key + " = \\[ (('[^\']+', )+) \\];");
- if (rx.indexIn(m_data) != -1) {
- QString temp = rx.cap(1);
- temp.remove('\'');
- temp.remove(' ');
- result = temp.split(',', QString::SkipEmptyParts);
- }
-
- qCDebug(DRKONQI_LOG) << "Found data for " + key + ':' << result << result.count();
- return result;
-}
-
-
diff --git a/src/gdbhighlighter.cpp b/src/gdbhighlighter.cpp
--- a/src/gdbhighlighter.cpp
+++ b/src/gdbhighlighter.cpp
@@ -67,7 +67,7 @@
diff = next - cur;
- QString lineStr = text.mid(cur, diff).append(QLatin1Char('\n'));
+ const QString lineStr = text.mid(cur, diff).append(QLatin1Char('\n'));
// -1 since we skip the first line
QMap< int, BacktraceLine >::iterator it = lines.lowerBound(lineNr - 1);
Q_ASSERT(it != lines.end());
diff --git a/src/main.cpp b/src/main.cpp
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -195,6 +195,5 @@
int ret = qa.exec();
- DrKonqi::cleanup();
return ret;
}
diff --git a/src/statusnotifier.cpp b/src/statusnotifier.cpp
--- a/src/statusnotifier.cpp
+++ b/src/statusnotifier.cpp
@@ -121,9 +121,7 @@
QStringList actions = {i18nc("Notification action button, keep short", "Report Bug")};
- bool restartEnabled = canBeRestarted(crashedApp);
-
- if (restartEnabled) {
+ if (canBeRestarted(crashedApp)) {
actions << i18nc("Notification action button, keep short", "Restart App");
}