Handle NULL / nil in toOF() / toQt()
This commit is contained in:
parent
dcc0d5e48a
commit
5fb2a587b6
14 changed files with 48 additions and 3 deletions
|
@ -42,6 +42,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtChildEvent *
|
||||
toOF(QChildEvent *qChildEvent)
|
||||
{
|
||||
if (qChildEvent == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtChildEvent alloc]
|
||||
initWithQChildEvent: qChildEvent] autorelease];
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtCoreApplication *
|
||||
toOF(QCoreApplication *qCoreApplication)
|
||||
{
|
||||
if (qCoreApplication == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtCoreApplication alloc]
|
||||
initWithQCoreApplication: qCoreApplication] autorelease];
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtEvent *
|
||||
toOF(QEvent *qEvent)
|
||||
{
|
||||
if (qEvent == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtEvent alloc] initWithQEvent: qEvent] autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtObject *
|
||||
toOF(QObject *qObject)
|
||||
{
|
||||
if (qObject == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtObject alloc] initWithQObject: qObject] autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtThread *
|
||||
toOF(QThread *qThread)
|
||||
{
|
||||
if (qThread == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtThread alloc] initWithQThread: qThread] autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtGUIApplication *
|
||||
toOF(QGuiApplication *qGuiApplication)
|
||||
{
|
||||
if (qGuiApplication == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtGUIApplication alloc]
|
||||
initWithQGuiApplication: qGuiApplication] autorelease];
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtAbstractButton *
|
||||
toOF(QAbstractButton *qAbstractButton)
|
||||
{
|
||||
if (qAbstractButton == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtAbstractButton alloc]
|
||||
initWithQAbstractButton: qAbstractButton] autorelease];
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtAction *
|
||||
toOF(QAction *qAction)
|
||||
{
|
||||
if (qAction == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtAction alloc] initWithQAction: qAction] autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtApplication *
|
||||
toOF(QApplication *qApplication)
|
||||
{
|
||||
if (qApplication == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtApplication alloc]
|
||||
initWithQApplication: qApplication] autorelease];
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtPushButton *
|
||||
toOF(QPushButton *qPushButton)
|
||||
{
|
||||
if (qPushButton == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtPushButton alloc]
|
||||
initWithQPushButton: qPushButton] autorelease];
|
||||
}
|
||||
|
|
|
@ -229,6 +229,9 @@ namespace ObjQt {
|
|||
static OF_INLINE QtWidget *
|
||||
toOF(QWidget *qWidget)
|
||||
{
|
||||
if (qWidget == NULL)
|
||||
return nil;
|
||||
|
||||
return [[[QtWidget alloc] initWithQWidget: qWidget] autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,18 @@ namespace ObjQt {
|
|||
static OF_INLINE OFDataArray *
|
||||
toOF(const QByteArray &qByteArray)
|
||||
{
|
||||
if (qByteArray.isNull())
|
||||
return nil;
|
||||
|
||||
return [OFDataArray dataArrayWithQByteArray: qByteArray];
|
||||
}
|
||||
|
||||
static OF_INLINE QByteArray
|
||||
toQt(OFDataArray *dataArray)
|
||||
{
|
||||
if (dataArray == nil)
|
||||
return QByteArray();
|
||||
|
||||
return [dataArray qByteArray];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,18 @@ namespace ObjQt {
|
|||
static OF_INLINE OFString *
|
||||
toOF(const QString &qString)
|
||||
{
|
||||
if (qString.isNull())
|
||||
return nil;
|
||||
|
||||
return [OFString stringWithQString: qString];
|
||||
}
|
||||
|
||||
static OF_INLINE QString
|
||||
toQt(OFString *string)
|
||||
{
|
||||
if (string == nil)
|
||||
return QString();
|
||||
|
||||
return [string qString];
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ toOF(const QPoint &qPoint)
|
|||
}
|
||||
|
||||
static OF_INLINE QPoint
|
||||
toQt(of_point_t point)
|
||||
toQt(const of_point_t &point)
|
||||
{
|
||||
return QPoint(point.x, point.y);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ toOF(const QSize &qSize)
|
|||
}
|
||||
|
||||
static OF_INLINE QSize
|
||||
toQt(of_dimension_t dimension)
|
||||
toQt(const of_dimension_t &dimension)
|
||||
{
|
||||
return QSize(dimension.width, dimension.height);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ toOF(const QRect &qRect)
|
|||
}
|
||||
|
||||
static OF_INLINE QRect
|
||||
toQt(of_rectangle_t rectangle)
|
||||
toQt(const of_rectangle_t &rectangle)
|
||||
{
|
||||
return QRect(rectangle.origin.x, rectangle.origin.y,
|
||||
rectangle.size.width, rectangle.size.height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue