mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55: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);
|
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);
|
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()
|
CConnectionGuard::~CConnectionGuard()
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ namespace BlackMisc
|
|||||||
~CConnectionGuard();
|
~CConnectionGuard();
|
||||||
|
|
||||||
//! Add connection
|
//! Add connection
|
||||||
void append(const QMetaObject::Connection &connection);
|
bool append(const QMetaObject::Connection &connection);
|
||||||
|
|
||||||
//! Add connections
|
//! Add connections
|
||||||
void append(const QList<QMetaObject::Connection> &connections);
|
bool append(const QList<QMetaObject::Connection> &connections);
|
||||||
|
|
||||||
//! Disconnect all
|
//! Disconnect all
|
||||||
int disconnectAll();
|
int disconnectAll();
|
||||||
@@ -61,6 +61,6 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
QList<QMetaObject::Connection> m_connections;
|
QList<QMetaObject::Connection> m_connections;
|
||||||
};
|
};
|
||||||
} // BlackMisc
|
} // ns
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user