Handle NULL / nil in toOF() / toQt()

This commit is contained in:
Jonathan Schleifer 2017-05-14 03:07:21 +02:00
parent dcc0d5e48a
commit 5fb2a587b6
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
14 changed files with 48 additions and 3 deletions

View file

@ -42,6 +42,9 @@ namespace ObjQt {
static OF_INLINE QtChildEvent *
toOF(QChildEvent *qChildEvent)
{
if (qChildEvent == NULL)
return nil;
return [[[QtChildEvent alloc]
initWithQChildEvent: qChildEvent] autorelease];
}

View file

@ -45,6 +45,9 @@ namespace ObjQt {
static OF_INLINE QtCoreApplication *
toOF(QCoreApplication *qCoreApplication)
{
if (qCoreApplication == NULL)
return nil;
return [[[QtCoreApplication alloc]
initWithQCoreApplication: qCoreApplication] autorelease];
}

View file

@ -49,6 +49,9 @@ namespace ObjQt {
static OF_INLINE QtEvent *
toOF(QEvent *qEvent)
{
if (qEvent == NULL)
return nil;
return [[[QtEvent alloc] initWithQEvent: qEvent] autorelease];
}

View file

@ -87,6 +87,9 @@ namespace ObjQt {
static OF_INLINE QtObject *
toOF(QObject *qObject)
{
if (qObject == NULL)
return nil;
return [[[QtObject alloc] initWithQObject: qObject] autorelease];
}

View file

@ -50,6 +50,9 @@ namespace ObjQt {
static OF_INLINE QtThread *
toOF(QThread *qThread)
{
if (qThread == NULL)
return nil;
return [[[QtThread alloc] initWithQThread: qThread] autorelease];
}

View file

@ -51,6 +51,9 @@ namespace ObjQt {
static OF_INLINE QtGUIApplication *
toOF(QGuiApplication *qGuiApplication)
{
if (qGuiApplication == NULL)
return nil;
return [[[QtGUIApplication alloc]
initWithQGuiApplication: qGuiApplication] autorelease];
}

View file

@ -49,6 +49,9 @@ namespace ObjQt {
static OF_INLINE QtAbstractButton *
toOF(QAbstractButton *qAbstractButton)
{
if (qAbstractButton == NULL)
return nil;
return [[[QtAbstractButton alloc]
initWithQAbstractButton: qAbstractButton] autorelease];
}

View file

@ -71,6 +71,9 @@ namespace ObjQt {
static OF_INLINE QtAction *
toOF(QAction *qAction)
{
if (qAction == NULL)
return nil;
return [[[QtAction alloc] initWithQAction: qAction] autorelease];
}

View file

@ -47,6 +47,9 @@ namespace ObjQt {
static OF_INLINE QtApplication *
toOF(QApplication *qApplication)
{
if (qApplication == NULL)
return nil;
return [[[QtApplication alloc]
initWithQApplication: qApplication] autorelease];
}

View file

@ -45,6 +45,9 @@ namespace ObjQt {
static OF_INLINE QtPushButton *
toOF(QPushButton *qPushButton)
{
if (qPushButton == NULL)
return nil;
return [[[QtPushButton alloc]
initWithQPushButton: qPushButton] autorelease];
}

View file

@ -229,6 +229,9 @@ namespace ObjQt {
static OF_INLINE QtWidget *
toOF(QWidget *qWidget)
{
if (qWidget == NULL)
return nil;
return [[[QtWidget alloc] initWithQWidget: qWidget] autorelease];
}

View file

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

View file

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

View file

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