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