mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Add get() and operator bool() to QObjectUniquePointer
This commit is contained in:
parent
8197e00c7b
commit
590f654f3f
@ -91,6 +91,14 @@ class QObjectUniquePtr
|
||||
return static_cast<T *>( mPtr.data() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw pointer to the managed QObject.
|
||||
*/
|
||||
inline T *get() const
|
||||
{
|
||||
return static_cast<T *>( mPtr.data() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a raw pointer to the managed QObject.
|
||||
*/
|
||||
@ -123,6 +131,11 @@ class QObjectUniquePtr
|
||||
return mPtr.isNull();
|
||||
}
|
||||
|
||||
inline bool operator bool() const
|
||||
{
|
||||
return !mPtr.isNull();
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
mPtr.clear();
|
||||
|
@ -43,9 +43,13 @@ void TestQObjectUniquePtr::testParentDeletedFirst()
|
||||
|
||||
QObjectUniquePtr<QObject> obj( child );
|
||||
QVERIFY( !obj.isNull() );
|
||||
QVERIFY( obj );
|
||||
QCOMPARE( child, obj.get() );
|
||||
QCOMPARE( child, obj.data() );
|
||||
|
||||
delete parent;
|
||||
QVERIFY( obj.isNull() );
|
||||
QVERIFY( !obj );
|
||||
}
|
||||
|
||||
void TestQObjectUniquePtr::testParentDeletedAfter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user