Skip to content

Commit

Permalink
Fixed build under melodic which uses a Qt version that does not suppo…
Browse files Browse the repository at this point in the history
…rt functors yet for QMetaObject::invokeMethod.
  • Loading branch information
StefanFabian committed Mar 26, 2021
1 parent b475332 commit 4c91238
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/qml_ros_plugin/image_transport_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ImageTransportManager
ImageTransportManager();

struct SubscriptionManager;
struct Subscription;
class Subscription;
public:

static ImageTransportManager &getInstance();
Expand Down
15 changes: 10 additions & 5 deletions src/image_transport_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "qml_ros_plugin/image_buffer.h"

#include <QTimer>
#include <mutex>

namespace qml_ros_plugin
{
Expand All @@ -21,8 +22,10 @@ struct ImageTransportManager::SubscriptionManager
std::unique_ptr<image_transport::ImageTransport> transport;
};

struct ImageTransportManager::Subscription : public QObject
class ImageTransportManager::Subscription : public QObject
{
Q_OBJECT
public:
ImageTransportManager *manager = nullptr;
std::shared_ptr<SubscriptionManager> subscription_manager;
std::string topic;
Expand Down Expand Up @@ -60,7 +63,7 @@ struct ImageTransportManager::Subscription : public QObject
}
}

void restartTimer()
Q_INVOKABLE void restartTimer()
{
int interval = getThrottleInterval();
int timeout = interval == 0 ? 0 : manager->getLoadBalancedTimeout( interval );
Expand Down Expand Up @@ -116,7 +119,7 @@ struct ImageTransportManager::Subscription : public QObject
if ( interval != 0 && interval > camera_base_interval_ )
{
subscriber_.shutdown();
QMetaObject::invokeMethod( this, &Subscription::restartTimer, Qt::AutoConnection );
QMetaObject::invokeMethod( this, "restartTimer", Qt::AutoConnection );
throttled_ = true;
}
QList<QVideoFrame::PixelFormat> formats;
Expand All @@ -143,10 +146,10 @@ struct ImageTransportManager::Subscription : public QObject
last_buffer_ = buffer;
}
// Deliver frames on UI thread
QMetaObject::invokeMethod( this, &Subscription::imageDelivery, Qt::AutoConnection );
QMetaObject::invokeMethod( this, "imageDelivery", Qt::AutoConnection );
}

void imageDelivery()
Q_INVOKABLE void imageDelivery()
{
ImageBuffer *buffer;
sensor_msgs::ImageConstPtr image;
Expand Down Expand Up @@ -347,3 +350,5 @@ void ImageTransportManagerSingletonWrapper::setLoadBalancingEnabled( bool value
ImageTransportManager::getInstance().setLoadBalancingEnabled( value );
}
}

#include "image_transport_manager.moc"

0 comments on commit 4c91238

Please sign in to comment.