Skip to content

Commit

Permalink
clang-tidy;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Aug 17, 2023
1 parent b09bc08 commit d2d9cc8
Show file tree
Hide file tree
Showing 117 changed files with 987 additions and 1,053 deletions.
47 changes: 1 addition & 46 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,10 @@ AnalyzeTemporaryDtors: false
FormatStyle: file
User: user
CheckOptions:
- key: readability-identifier-naming.AbstractClassCase
value: CamelCase
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ClassConstantPrefix
value: 'k'
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ClassMemberPrefix
value: 'm_'
- key: readability-identifier-naming.ClassMethodCase
value: camelBack
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstexprVariablePrefix
value: 'k'
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.EnumConstantPrefix
value: ''
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.FunctionParameterCase
value: lower_case
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.GlobalConstantPrefix
value: 'k'
- key: readability-identifier-naming.GlobalFunctionCase
value: camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: lower_case
- key: readability-identifier-naming.GlobalVariablePrefix
value: 'g_'
- key: readability-identifier-naming.InlineNamespaceCase
value: lower_case
- key: readability-identifier-naming.LocalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.LocalConstantPrefix
value: 'k'
- key: readability-identifier-naming.LocalVariableCase
value: lower_case
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: bugprone-narrowing-conversions.IgnoreFloatingPointPrecisionLoss
value: 'false'

4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- '.clang-format'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- '.clang-format'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- '.clang-format'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- 'doc/**'
- '.clang-format'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/breakpad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class THRIDPARTY_EXPORT BreakPad : public QObject
{
Q_OBJECT
public:
static BreakPad *instance();
static auto instance() -> BreakPad *;

signals:
void crash();

private:
explicit BreakPad(QObject *parent = nullptr);
~BreakPad();
~BreakPad() override;

struct BreakPadPrivate;
QScopedPointer<BreakPadPrivate> d_ptr;
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/qtlockedfile/qtlockedfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ QtLockedFile::QtLockedFile(const QString &name)
\sa lockMode()
*/
bool QtLockedFile::isLocked() const
auto QtLockedFile::isLocked() const -> bool
{
return m_lock_mode != NoLock;
}
Expand All @@ -108,7 +108,7 @@ bool QtLockedFile::isLocked() const
\sa isLocked()
*/
QtLockedFile::LockMode QtLockedFile::lockMode() const
auto QtLockedFile::lockMode() const -> QtLockedFile::LockMode
{
return m_lock_mode;
}
Expand Down
12 changes: 6 additions & 6 deletions 3rdparty/qtlockedfile/qtlockedfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
enum LockMode { NoLock = 0, ReadLock, WriteLock };

QtLockedFile();
QtLockedFile(const QString &name);
~QtLockedFile();
explicit QtLockedFile(const QString &name);
~QtLockedFile() override;

bool lock(LockMode mode, bool block = true);
bool unlock();
bool isLocked() const;
LockMode lockMode() const;
auto lock(LockMode mode, bool block = true) -> bool;
auto unlock() -> bool;
[[nodiscard]] auto isLocked() const -> bool;
[[nodiscard]] auto lockMode() const -> LockMode;

private:
#ifdef Q_OS_WIN
Expand Down
8 changes: 4 additions & 4 deletions 3rdparty/qtlockedfile/qtlockedfile_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace SharedTools {
#define MUTEX_PREFIX "QtLockedFile mutex "
#define SEMAPHORE_MAX 100

static QString errorCodeToString(DWORD errorCode)
static auto errorCodeToString(DWORD errorCode) -> QString
{
QString result;
char *data = 0;
Expand All @@ -51,7 +51,7 @@ static QString errorCodeToString(DWORD errorCode)
return result;
}

bool QtLockedFile::lock(LockMode mode, bool block)
auto QtLockedFile::lock(LockMode mode, bool block) -> bool
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
Expand Down Expand Up @@ -112,7 +112,7 @@ bool QtLockedFile::lock(LockMode mode, bool block)
for (int i = 0; i < decrement; ++i) {
DWORD res = WaitForSingleObject(m_semaphore_hnd, block ? INFINITE : 0);
if (res == WAIT_TIMEOUT) {
if (i) {
if (i != 0) {
// A failed nonblocking rw locking. Undo changes to semaphore.
if (ReleaseSemaphore(m_semaphore_hnd, i, NULL) == 0) {
qWarning("QtLockedFile::unlock(): ReleaseSemaphore: %s",
Expand All @@ -139,7 +139,7 @@ bool QtLockedFile::lock(LockMode mode, bool block)
return true;
}

bool QtLockedFile::unlock()
auto QtLockedFile::unlock() -> bool
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
Expand Down
16 changes: 8 additions & 8 deletions 3rdparty/qtsingleapplication/qtlocalpeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace SharedTools {

static const char ack[] = "ack";

QString QtLocalPeer::appSessionId(const QString &appId)
auto QtLocalPeer::appSessionId(const QString &appId) -> QString
{
QByteArray idc = appId.toUtf8();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Expand All @@ -59,11 +59,11 @@ QString QtLocalPeer::appSessionId(const QString &appId)
QString res = QLatin1String("qtsingleapplication-")
+ QString::number(idNum, 16);
#if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) {
if (pProcessIdToSessionId == nullptr) {
QLibrary lib(QLatin1String("kernel32"));
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
}
if (pProcessIdToSessionId) {
if (pProcessIdToSessionId != nullptr) {
DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
res += QLatin1Char('-') + QString::number(sessionId, 16);
Expand All @@ -89,7 +89,7 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId)
lockFile.open(QIODevice::ReadWrite);
}

bool QtLocalPeer::isClient()
auto QtLocalPeer::isClient() -> bool
{
if (lockFile.isLocked())
return false;
Expand All @@ -106,7 +106,7 @@ bool QtLocalPeer::isClient()
return false;
}

bool QtLocalPeer::sendMessage(const QString &message, int timeout, bool block)
auto QtLocalPeer::sendMessage(const QString &message, int timeout, bool block) -> bool
{
if (!isClient())
return false;
Expand All @@ -117,7 +117,7 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout, bool block)
// Try twice, in case the other instance is just starting up
socket.connectToServer(socketName);
connOk = socket.waitForConnected(timeout/2);
if (connOk || i)
if (connOk || (i != 0))
break;
int ms = 250;
#if defined(Q_OS_WIN)
Expand All @@ -144,7 +144,7 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout, bool block)
void QtLocalPeer::receiveConnection()
{
QLocalSocket* socket = server->nextPendingConnection();
if (!socket)
if (socket == nullptr)
return;

// Why doesn't Qt have a blocking stream that takes care of this shait???
Expand All @@ -166,7 +166,7 @@ void QtLocalPeer::receiveConnection()
remaining -= got;
uMsgBuf += got;
//qDebug() << "RCV: got" << got << "remaining" << remaining;
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
} while ((remaining != 0u) && got >= 0 && socket->waitForReadyRead(2000));
//### error check: got<0
if (got < 0) {
qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString();
Expand Down
8 changes: 4 additions & 4 deletions 3rdparty/qtsingleapplication/qtlocalpeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class QtLocalPeer : public QObject

public:
explicit QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
bool isClient();
bool sendMessage(const QString &message, int timeout, bool block);
QString applicationId() const
auto isClient() -> bool;
auto sendMessage(const QString &message, int timeout, bool block) -> bool;
[[nodiscard]] auto applicationId() const -> QString
{ return id; }
static QString appSessionId(const QString &appId);
static auto appSessionId(const QString &appId) -> QString;

Q_SIGNALS:
void messageReceived(const QString &message, QObject *socket);
Expand Down
22 changes: 11 additions & 11 deletions 3rdparty/qtsingleapplication/qtsingleapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace SharedTools {

static const int instancesSize = 1024;

static QString instancesLockFilename(const QString &appSessionId)
static auto instancesLockFilename(const QString &appSessionId) -> QString
{
const QChar slash(QLatin1Char('/'));
QString res = QDir::tempPath();
Expand Down Expand Up @@ -81,7 +81,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
if (!created) {
// Find the first instance that it still running
// The whole list needs to be iterated in order to append to it
for (; *pids; ++pids) {
for (; *pids != 0; ++pids) {
if (firstPeer == -1 && isRunning(*pids))
firstPeer = *pids;
}
Expand All @@ -98,7 +98,7 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *

QtSingleApplication::~QtSingleApplication()
{
if (!instances)
if (instances == nullptr)
return;
const qint64 appPid = QCoreApplication::applicationPid();
QtLockedFile lockfile(instancesLockFilename(QtLocalPeer::appSessionId(appId)));
Expand All @@ -107,15 +107,15 @@ QtSingleApplication::~QtSingleApplication()
// Rewrite array, removing current pid and previously crashed ones
qint64 *pids = static_cast<qint64 *>(instances->data());
qint64 *newpids = pids;
for (; *pids; ++pids) {
for (; *pids != 0; ++pids) {
if (*pids != appPid && isRunning(*pids))
*newpids++ = *pids;
}
*newpids = 0;
lockfile.unlock();
}

bool QtSingleApplication::event(QEvent *event)
auto QtSingleApplication::event(QEvent *event) -> bool
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *foe = static_cast<QFileOpenEvent*>(event);
Expand All @@ -125,7 +125,7 @@ bool QtSingleApplication::event(QEvent *event)
return QApplication::event(event);
}

bool QtSingleApplication::isRunning(qint64 pid)
auto QtSingleApplication::isRunning(qint64 pid) -> bool
{
if (pid == -1) {
pid = firstPeer;
Expand All @@ -137,7 +137,7 @@ bool QtSingleApplication::isRunning(qint64 pid)
return peer.isClient();
}

bool QtSingleApplication::sendMessage(const QString &message, int timeout, qint64 pid)
auto QtSingleApplication::sendMessage(const QString &message, int timeout, qint64 pid) -> bool
{
if (pid == -1) {
pid = firstPeer;
Expand All @@ -149,7 +149,7 @@ bool QtSingleApplication::sendMessage(const QString &message, int timeout, qint6
return peer.sendMessage(message, timeout, block);
}

QString QtSingleApplication::applicationId() const
auto QtSingleApplication::applicationId() const -> QString
{
return appId;
}
Expand All @@ -162,7 +162,7 @@ void QtSingleApplication::setBlock(bool value)
void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage)
{
actWin = aw;
if (!pidPeer)
if (pidPeer == nullptr)
return;
if (activateOnMessage)
connect(pidPeer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow);
Expand All @@ -171,15 +171,15 @@ void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessag
}


QWidget* QtSingleApplication::activationWindow() const
auto QtSingleApplication::activationWindow() const -> QWidget*
{
return actWin;
}


void QtSingleApplication::activateWindow()
{
if (actWin) {
if (actWin != nullptr) {
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
actWin->raise();
actWin->activateWindow();
Expand Down
14 changes: 7 additions & 7 deletions 3rdparty/qtsingleapplication/qtsingleapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ class THRIDPARTY_EXPORT QtSingleApplication : public QApplication

public:
QtSingleApplication(const QString &id, int &argc, char **argv);
~QtSingleApplication();
~QtSingleApplication() override;

bool isRunning(qint64 pid = -1);
auto isRunning(qint64 pid = -1) -> bool;

void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
QWidget* activationWindow() const;
bool event(QEvent *event) override;
[[nodiscard]] auto activationWindow() const -> QWidget*;
auto event(QEvent *event) -> bool override;

QString applicationId() const;
[[nodiscard]] auto applicationId() const -> QString;
void setBlock(bool value);

bool sendMessage(const QString &message, int timeout = 5000, qint64 pid = -1);
auto sendMessage(const QString &message, int timeout = 5000, qint64 pid = -1) -> bool;
void activateWindow();

Q_SIGNALS:
void messageReceived(const QString &message, QObject *socket);
void fileOpenRequest(const QString &file);

private:
QString instancesFileName(const QString &appId);
auto instancesFileName(const QString &appId) -> QString;

qint64 firstPeer;
QSharedMemory *instances;
Expand Down
Loading

0 comments on commit d2d9cc8

Please sign in to comment.