From 7ba02666d10e5685dec9c3ee9facaa000d9e0bab Mon Sep 17 00:00:00 2001 From: Alfredo Ramos Date: Sat, 28 Jul 2018 17:17:50 -0500 Subject: [PATCH] Fix most of the issues reported by cppcheck (#290) --- src/core/capturerequest.h | 6 +++--- src/tools/abstractactiontool.h | 2 +- src/tools/abstractpathtool.h | 4 ++-- src/tools/abstracttwopointtool.h | 4 ++-- src/tools/imgur/imguruploader.h | 2 +- src/utils/dbusutils.cpp | 4 ++-- src/utils/desktopfileparse.h | 6 +++--- src/utils/systemnotification.cpp | 2 +- src/widgets/capture/capturewidget.cpp | 6 +++--- src/widgets/capture/selectionwidget.h | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/core/capturerequest.h b/src/core/capturerequest.h index c0d6814b..fc65c8b3 100644 --- a/src/core/capturerequest.h +++ b/src/core/capturerequest.h @@ -65,15 +65,15 @@ private: using eTask = CaptureRequest::ExportTask; -inline eTask operator|(eTask a, eTask b) { +inline eTask operator|(const eTask &a, const eTask &b) { return static_cast(static_cast(a) | static_cast(b)); } -inline eTask operator&(eTask a, eTask b) { +inline eTask operator&(const eTask &a, const eTask &b) { return static_cast(static_cast(a) & static_cast(b)); } -inline eTask& operator|=(eTask &a, eTask b) { +inline eTask& operator|=(eTask &a, const eTask &b) { a = static_cast(static_cast(a) | static_cast(b)); return a; } diff --git a/src/tools/abstractactiontool.h b/src/tools/abstractactiontool.h index e8c2f55f..a96427ff 100644 --- a/src/tools/abstractactiontool.h +++ b/src/tools/abstractactiontool.h @@ -24,7 +24,7 @@ class AbstractActionTool : public CaptureTool { public: explicit AbstractActionTool(QObject *parent = nullptr); - bool isValid() const; + bool isValid() const override; bool isSelectable() const override; bool showMousePreview() const override; diff --git a/src/tools/abstractpathtool.h b/src/tools/abstractpathtool.h index 4c329cf9..f6554f3f 100644 --- a/src/tools/abstractpathtool.h +++ b/src/tools/abstractpathtool.h @@ -24,8 +24,8 @@ class AbstractPathTool : public CaptureTool { public: explicit AbstractPathTool(QObject *parent = nullptr); - bool isValid() const; - bool closeOnButtonPressed() const; + bool isValid() const override; + bool closeOnButtonPressed() const override; bool isSelectable() const override; bool showMousePreview() const override; diff --git a/src/tools/abstracttwopointtool.h b/src/tools/abstracttwopointtool.h index d2db8cb0..1f360028 100644 --- a/src/tools/abstracttwopointtool.h +++ b/src/tools/abstracttwopointtool.h @@ -24,8 +24,8 @@ class AbstractTwoPointTool : public CaptureTool { public: explicit AbstractTwoPointTool(QObject *parent = nullptr); - bool isValid() const; - bool closeOnButtonPressed() const; + bool isValid() const override; + bool closeOnButtonPressed() const override; bool isSelectable() const override; bool showMousePreview() const override; diff --git a/src/tools/imgur/imguruploader.h b/src/tools/imgur/imguruploader.h index b949289e..870d5c0c 100644 --- a/src/tools/imgur/imguruploader.h +++ b/src/tools/imgur/imguruploader.h @@ -33,7 +33,7 @@ class NotificationWidget; class ImgurUploader : public QWidget { Q_OBJECT public: - explicit ImgurUploader(const QPixmap &p, QWidget *parent = nullptr); + explicit ImgurUploader(const QPixmap &capture, QWidget *parent = nullptr); private slots: void handleReply(QNetworkReply *reply); diff --git a/src/utils/dbusutils.cpp b/src/utils/dbusutils.cpp index 51394510..d9bb6405 100644 --- a/src/utils/dbusutils.cpp +++ b/src/utils/dbusutils.cpp @@ -38,8 +38,8 @@ void DBusUtils::connectPrintCapture(QDBusConnection &session, uint id) { SLOT(captureFailed(uint))); } -void DBusUtils::checkDBusConnection(const QDBusConnection &c) { - if (!c.isConnected()) { +void DBusUtils::checkDBusConnection(const QDBusConnection &connection) { + if (!connection.isConnected()) { SystemNotification().sendMessage(tr("Unable to connect via DBus")); qApp->exit(); } diff --git a/src/utils/desktopfileparse.h b/src/utils/desktopfileparse.h index 55a4e796..466e132b 100644 --- a/src/utils/desktopfileparse.h +++ b/src/utils/desktopfileparse.h @@ -29,9 +29,9 @@ struct DesktopAppData { DesktopAppData() : showInTerminal() {} DesktopAppData( - QString name, - QString description, - QString exec, + const QString &name, + const QString &description, + const QString &exec, QIcon icon) : name(name), description(description), diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index d2edb364..ac92f6fe 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -20,7 +20,7 @@ SystemNotification::SystemNotification(QObject *parent) : QObject(parent) { } #else SystemNotification::SystemNotification(QObject *parent) : QObject(parent) { - + m_interface = nullptr; } #endif diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 8c00c9f0..a07fee7f 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -49,7 +49,7 @@ // enableSaveWIndow CaptureWidget::CaptureWidget(const uint id, const QString &savePath, - bool fullscreen, QWidget *parent) : + bool fullScreen, QWidget *parent) : QWidget(parent), m_mouseIsClicked(false), m_rightClick(false), m_newSelection(false), m_grabbing(false), m_captureDone(false), m_previewEnabled(true), m_activeButton(nullptr), @@ -66,14 +66,14 @@ CaptureWidget::CaptureWidget(const uint id, const QString &savePath, m_showInitialMsg = m_config.showHelpValue(); m_opacity = m_config.contrastOpacityValue(); setMouseTracking(true); - initContext(savePath, fullscreen); + initContext(savePath, fullScreen); initShortcuts(); #ifdef Q_OS_WIN // Top left of the whole set of screens QPoint topLeft(0,0); #endif - if (fullscreen) { + if (fullScreen) { // Grab Screenshot bool ok = true; m_context.screenshot = ScreenGrabber().grabEntireDesktop(ok); diff --git a/src/widgets/capture/selectionwidget.h b/src/widgets/capture/selectionwidget.h index 0139a32c..df63c92d 100644 --- a/src/widgets/capture/selectionwidget.h +++ b/src/widgets/capture/selectionwidget.h @@ -39,7 +39,7 @@ public: explicit SelectionWidget(const QColor &c, QWidget *parent = nullptr); - SideType getMouseSide(const QPoint &p) const; + SideType getMouseSide(const QPoint &point) const; QVector handlerAreas(); void setGeometryAnimated(const QRect &r);