Skip to content

Commit

Permalink
Add missing sip subclass convertion code
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Mar 19, 2023
1 parent a2fe78a commit 11566ce
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/core/auto_generated/sensor/qgsabstractsensor.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,33 @@ An abstract base class for sensor classes

%TypeHeaderCode
#include "qgsabstractsensor.h"
#include "qgsiodevicesensor.h"
#include "qgssensorregistry.h"
%End
%ConvertToSubClassCode
if ( QgsAbstractSensor *item = qobject_cast< QgsAbstractSensor * >( sipCpp ) )
{
if ( item->type() == QgsSensorRegistry::TcpSocket && dynamic_cast<QgsTcpSocketSensor *>( item ) != NULL )
{
sipType = sipType_QgsTcpSocketSensor;
}
else if ( item->type() == QgsSensorRegistry::UdpSocket && dynamic_cast<QgsUdpSocketSensor *>( item ) != NULL )
{
sipType = sipType_QgsUdpSocketSensor;
}
else if ( item->type() == QgsSensorRegistry::SerialPort && dynamic_cast<QgsSerialPortSensor *>( item ) != NULL )
{
sipType = sipType_QgsSerialPortSensor;
}
else
{
sipType = sipType_QgsAbstractSensor;
}
}
else
{
sipType = NULL;
}
%End
public:

Expand Down
33 changes: 33 additions & 0 deletions src/core/sensor/qgsabstractsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,39 @@
*/
class CORE_EXPORT QgsAbstractSensor : public QObject
{
#ifdef SIP_RUN
#include "qgsiodevicesensor.h"
#include "qgssensorregistry.h"
#endif


#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
if ( QgsAbstractSensor *item = qobject_cast< QgsAbstractSensor * >( sipCpp ) )
{
if ( item->type() == QgsSensorRegistry::TcpSocket && dynamic_cast<QgsTcpSocketSensor *>( item ) != NULL )
{
sipType = sipType_QgsTcpSocketSensor;
}
else if ( item->type() == QgsSensorRegistry::UdpSocket && dynamic_cast<QgsUdpSocketSensor *>( item ) != NULL )
{
sipType = sipType_QgsUdpSocketSensor;
}
else if ( item->type() == QgsSensorRegistry::SerialPort && dynamic_cast<QgsSerialPortSensor *>( item ) != NULL )
{
sipType = sipType_QgsSerialPortSensor;
}
else
{
sipType = sipType_QgsAbstractSensor;
}
}
else
{
sipType = NULL;
}
SIP_END
#endif

Q_OBJECT

Expand Down

0 comments on commit 11566ce

Please sign in to comment.