Consider QObject could be null in CSlot

This commit is contained in:
Roland Winklmeier
2016-05-25 16:58:59 +02:00
parent 4b441c5d56
commit 26a72d5eb2
4 changed files with 97 additions and 3 deletions

View File

@@ -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;