mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Consider QObject could be null in CSlot
This commit is contained in:
@@ -62,13 +62,13 @@ namespace BlackMisc
|
||||
//! True if the slot can be called, false if it is empty.
|
||||
operator bool() const
|
||||
{
|
||||
return !this->isEmpty();
|
||||
return !this->isEmpty() && !this->hasNullObject();
|
||||
}
|
||||
|
||||
//! True if the slot is empty, false if it can be called.
|
||||
//! True if the slot is empty or object is null, false if it can be called.
|
||||
bool operator !() const
|
||||
{
|
||||
return this->isEmpty();
|
||||
return this->isEmpty() || this->hasNullObject();
|
||||
}
|
||||
|
||||
//! True if the slot is empty, false if it can be called.
|
||||
@@ -77,6 +77,12 @@ namespace BlackMisc
|
||||
return ! m_function;
|
||||
}
|
||||
|
||||
//! True if the object is null
|
||||
bool hasNullObject() const
|
||||
{
|
||||
return m_object.isNull();
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<QObject> m_object;
|
||||
std::function<R(Args...)> m_function;
|
||||
|
||||
Reference in New Issue
Block a user