1
0
mirror of https://github.com/itay-grudev/SingleApplication.git synced 2025-04-01 01:52:39 +08:00

Merge pull request #104 from Shatur95/fix_clang_tidy_warnings

Fix Clang Tidy warnings
This commit is contained in:
Itay Grudev 2020-05-25 06:59:05 +01:00 committed by GitHub
commit 84e225109d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 16 deletions

View File

@ -85,7 +85,7 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
} }
} }
InstancesInfo* inst = static_cast<InstancesInfo*>( d->memory->data() ); auto *inst = static_cast<InstancesInfo*>( d->memory->data() );
QElapsedTimer time; QElapsedTimer time;
time.start(); time.start();
@ -184,7 +184,7 @@ QString SingleApplication::currentUser()
return d->getUsername(); return d->getUsername();
} }
bool SingleApplication::sendMessage( QByteArray message, int timeout ) bool SingleApplication::sendMessage( const QByteArray &message, int timeout )
{ {
Q_D(SingleApplication); Q_D(SingleApplication);

View File

@ -43,7 +43,7 @@ class SingleApplication : public QAPPLICATION_CLASS
{ {
Q_OBJECT Q_OBJECT
typedef QAPPLICATION_CLASS app_t; using app_t = QAPPLICATION_CLASS;
public: public:
/** /**
@ -86,7 +86,7 @@ public:
* @see See the corresponding QAPPLICATION_CLASS constructor for reference * @see See the corresponding QAPPLICATION_CLASS constructor for reference
*/ */
explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 ); explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
~SingleApplication(); ~SingleApplication() override;
/** /**
* @brief Returns if the instance is the primary instance * @brief Returns if the instance is the primary instance
@ -131,7 +131,7 @@ public:
* @note sendMessage() will return false if invoked from the primary * @note sendMessage() will return false if invoked from the primary
* instance. * instance.
*/ */
bool sendMessage( QByteArray message, int timeout = 100 ); bool sendMessage( const QByteArray &message, int timeout = 100 );
Q_SIGNALS: Q_SIGNALS:
void instanceStarted(); void instanceStarted();

View File

@ -71,7 +71,7 @@ SingleApplicationPrivate::~SingleApplicationPrivate()
if( memory != nullptr ) { if( memory != nullptr ) {
memory->lock(); memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data()); auto *inst = static_cast<InstancesInfo*>(memory->data());
if( server != nullptr ) { if( server != nullptr ) {
server->close(); server->close();
delete server; delete server;
@ -149,7 +149,7 @@ void SingleApplicationPrivate::genBlockServerName()
void SingleApplicationPrivate::initializeMemoryBlock() void SingleApplicationPrivate::initializeMemoryBlock()
{ {
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() ); auto *inst = static_cast<InstancesInfo*>( memory->data() );
inst->primary = false; inst->primary = false;
inst->secondary = 0; inst->secondary = 0;
inst->primaryPid = -1; inst->primaryPid = -1;
@ -183,7 +183,7 @@ void SingleApplicationPrivate::startPrimary()
); );
// Reset the number of connections // Reset the number of connections
InstancesInfo* inst = static_cast <InstancesInfo*>( memory->data() ); auto *inst = static_cast <InstancesInfo*>( memory->data() );
inst->primary = true; inst->primary = true;
inst->primaryPid = q->applicationPid(); inst->primaryPid = q->applicationPid();
@ -266,7 +266,7 @@ qint64 SingleApplicationPrivate::primaryPid()
qint64 pid; qint64 pid;
memory->lock(); memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() ); auto *inst = static_cast<InstancesInfo*>( memory->data() );
pid = inst->primaryPid; pid = inst->primaryPid;
memory->unlock(); memory->unlock();
@ -278,7 +278,7 @@ QString SingleApplicationPrivate::primaryUser()
QByteArray username; QByteArray username;
memory->lock(); memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() ); auto *inst = static_cast<InstancesInfo*>( memory->data() );
username = inst->primaryUser; username = inst->primaryUser;
memory->unlock(); memory->unlock();

View File

@ -46,11 +46,9 @@ struct InstancesInfo {
}; };
struct ConnectionInfo { struct ConnectionInfo {
explicit ConnectionInfo() : qint64 msgLen = 0;
msgLen(0), instanceId(0), stage(0) {} quint32 instanceId = 0;
qint64 msgLen; quint8 stage = 0;
quint32 instanceId;
quint8 stage;
}; };
class SingleApplicationPrivate : public QObject { class SingleApplicationPrivate : public QObject {
@ -70,7 +68,7 @@ public:
Q_DECLARE_PUBLIC(SingleApplication) Q_DECLARE_PUBLIC(SingleApplication)
SingleApplicationPrivate( SingleApplication *q_ptr ); SingleApplicationPrivate( SingleApplication *q_ptr );
~SingleApplicationPrivate(); ~SingleApplicationPrivate() override;
QString getUsername(); QString getUsername();
void genBlockServerName(); void genBlockServerName();