Index: src/QtCore/QtChildEvent.h ================================================================== --- src/QtCore/QtChildEvent.h +++ src/QtCore/QtChildEvent.h @@ -40,10 +40,13 @@ namespace ObjQt { static OF_INLINE QtChildEvent * toOF(QChildEvent *qChildEvent) { + if (qChildEvent == NULL) + return nil; + return [[[QtChildEvent alloc] initWithQChildEvent: qChildEvent] autorelease]; } static OF_INLINE QChildEvent * Index: src/QtCore/QtCoreApplication.h ================================================================== --- src/QtCore/QtCoreApplication.h +++ src/QtCore/QtCoreApplication.h @@ -43,10 +43,13 @@ namespace ObjQt { static OF_INLINE QtCoreApplication * toOF(QCoreApplication *qCoreApplication) { + if (qCoreApplication == NULL) + return nil; + return [[[QtCoreApplication alloc] initWithQCoreApplication: qCoreApplication] autorelease]; } static OF_INLINE QCoreApplication * Index: src/QtCore/QtEvent.h ================================================================== --- src/QtCore/QtEvent.h +++ src/QtCore/QtEvent.h @@ -47,10 +47,13 @@ namespace ObjQt { static OF_INLINE QtEvent * toOF(QEvent *qEvent) { + if (qEvent == NULL) + return nil; + return [[[QtEvent alloc] initWithQEvent: qEvent] autorelease]; } static OF_INLINE QEvent * toQt(QtEvent *event) Index: src/QtCore/QtObject.h ================================================================== --- src/QtCore/QtObject.h +++ src/QtCore/QtObject.h @@ -85,10 +85,13 @@ namespace ObjQt { static OF_INLINE QtObject * toOF(QObject *qObject) { + if (qObject == NULL) + return nil; + return [[[QtObject alloc] initWithQObject: qObject] autorelease]; } static OF_INLINE QObject * toQt(QtObject *object) Index: src/QtCore/QtThread.h ================================================================== --- src/QtCore/QtThread.h +++ src/QtCore/QtThread.h @@ -48,10 +48,13 @@ namespace ObjQt { static OF_INLINE QtThread * toOF(QThread *qThread) { + if (qThread == NULL) + return nil; + return [[[QtThread alloc] initWithQThread: qThread] autorelease]; } static OF_INLINE QThread * toQt(QtThread *thread) Index: src/QtGui/QtGUIApplication.h ================================================================== --- src/QtGui/QtGUIApplication.h +++ src/QtGui/QtGUIApplication.h @@ -49,10 +49,13 @@ namespace ObjQt { static OF_INLINE QtGUIApplication * toOF(QGuiApplication *qGuiApplication) { + if (qGuiApplication == NULL) + return nil; + return [[[QtGUIApplication alloc] initWithQGuiApplication: qGuiApplication] autorelease]; } static OF_INLINE QGuiApplication * Index: src/QtWidgets/QtAbstractButton.h ================================================================== --- src/QtWidgets/QtAbstractButton.h +++ src/QtWidgets/QtAbstractButton.h @@ -47,10 +47,13 @@ namespace ObjQt { static OF_INLINE QtAbstractButton * toOF(QAbstractButton *qAbstractButton) { + if (qAbstractButton == NULL) + return nil; + return [[[QtAbstractButton alloc] initWithQAbstractButton: qAbstractButton] autorelease]; } static OF_INLINE QAbstractButton * Index: src/QtWidgets/QtAction.h ================================================================== --- src/QtWidgets/QtAction.h +++ src/QtWidgets/QtAction.h @@ -69,10 +69,13 @@ namespace ObjQt { static OF_INLINE QtAction * toOF(QAction *qAction) { + if (qAction == NULL) + return nil; + return [[[QtAction alloc] initWithQAction: qAction] autorelease]; } static OF_INLINE QAction * toQt(QtAction *action) Index: src/QtWidgets/QtApplication.h ================================================================== --- src/QtWidgets/QtApplication.h +++ src/QtWidgets/QtApplication.h @@ -45,10 +45,13 @@ namespace ObjQt { static OF_INLINE QtApplication * toOF(QApplication *qApplication) { + if (qApplication == NULL) + return nil; + return [[[QtApplication alloc] initWithQApplication: qApplication] autorelease]; } static OF_INLINE QApplication * Index: src/QtWidgets/QtPushButton.h ================================================================== --- src/QtWidgets/QtPushButton.h +++ src/QtWidgets/QtPushButton.h @@ -43,10 +43,13 @@ namespace ObjQt { static OF_INLINE QtPushButton * toOF(QPushButton *qPushButton) { + if (qPushButton == NULL) + return nil; + return [[[QtPushButton alloc] initWithQPushButton: qPushButton] autorelease]; } static OF_INLINE QPushButton * Index: src/QtWidgets/QtWidget.h ================================================================== --- src/QtWidgets/QtWidget.h +++ src/QtWidgets/QtWidget.h @@ -227,10 +227,13 @@ namespace ObjQt { static OF_INLINE QtWidget * toOF(QWidget *qWidget) { + if (qWidget == NULL) + return nil; + return [[[QtWidget alloc] initWithQWidget: qWidget] autorelease]; } static OF_INLINE QWidget * toQt(QtWidget *widget) Index: src/common/OFDataArray+QByteArray.h ================================================================== --- src/common/OFDataArray+QByteArray.h +++ src/common/OFDataArray+QByteArray.h @@ -32,15 +32,21 @@ 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]; } } Index: src/common/OFString+QString.h ================================================================== --- src/common/OFString+QString.h +++ src/common/OFString+QString.h @@ -33,15 +33,21 @@ 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]; } } Index: src/common/helpers.h ================================================================== --- src/common/helpers.h +++ src/common/helpers.h @@ -39,11 +39,11 @@ { return of_point(qPoint.x(), qPoint.y()); } static OF_INLINE QPoint -toQt(of_point_t point) +toQt(const of_point_t &point) { return QPoint(point.x, point.y); } static OF_INLINE of_dimension_t @@ -51,11 +51,11 @@ { return of_dimension(qSize.width(), qSize.height()); } static OF_INLINE QSize -toQt(of_dimension_t dimension) +toQt(const of_dimension_t &dimension) { return QSize(dimension.width, dimension.height); } static OF_INLINE of_rectangle_t @@ -64,12 +64,12 @@ return of_rectangle(qRect.x(), qRect.y(), qRect.width(), qRect.height()); } 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); } }