mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Connection guard, only valid signal connections will be added
This commit is contained in:
@@ -17,14 +17,22 @@ namespace BlackMisc
|
||||
m_connections.append(connection);
|
||||
}
|
||||
|
||||
void CConnectionGuard::append(const QMetaObject::Connection &connection)
|
||||
bool CConnectionGuard::append(const QMetaObject::Connection &connection)
|
||||
{
|
||||
if (!connection) { return false; }
|
||||
m_connections.append(connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CConnectionGuard::append(const QList<QMetaObject::Connection> &connections)
|
||||
bool CConnectionGuard::append(const QList<QMetaObject::Connection> &connections)
|
||||
{
|
||||
m_connections.append(connections);
|
||||
int c = 0;
|
||||
for (const QMetaObject::Connection &connection : connections)
|
||||
{
|
||||
if (!connection) { continue; }
|
||||
if (this->append(connection)) { c++; }
|
||||
}
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
CConnectionGuard::~CConnectionGuard()
|
||||
|
||||
@@ -50,10 +50,10 @@ namespace BlackMisc
|
||||
~CConnectionGuard();
|
||||
|
||||
//! Add connection
|
||||
void append(const QMetaObject::Connection &connection);
|
||||
bool append(const QMetaObject::Connection &connection);
|
||||
|
||||
//! Add connections
|
||||
void append(const QList<QMetaObject::Connection> &connections);
|
||||
bool append(const QList<QMetaObject::Connection> &connections);
|
||||
|
||||
//! Disconnect all
|
||||
int disconnectAll();
|
||||
@@ -61,6 +61,6 @@ namespace BlackMisc
|
||||
private:
|
||||
QList<QMetaObject::Connection> m_connections;
|
||||
};
|
||||
} // BlackMisc
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user