Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport2/v5.12 #1335

Merged
merged 11 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# ========================= eCAL LICENSE =================================

cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.15)

include(CMakeDependentOption)

Expand Down
4 changes: 3 additions & 1 deletion app/meas_cutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ find_package(yaml-cpp REQUIRED)

#compatibility with yaml-cpp < 0.8.0
if (NOT TARGET yaml-cpp::yaml-cpp AND TARGET yaml-cpp)
add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp)
# ALIASing a imported non-global library requires CMake 3.18 so we do this
add_library(yaml-cpp::yaml-cpp INTERFACE IMPORTED)
target_link_libraries(yaml-cpp::yaml-cpp INTERFACE yaml-cpp)
endif()


Expand Down
14 changes: 10 additions & 4 deletions app/mon/mon_plugins/signals_plotting/src/signal_tree_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ Qt::ItemFlags SignalTreeModel::flags(const QModelIndex& index) const
QVariant SignalTreeModel::data(const QModelIndex& index, int role) const
{
QAbstractTreeItem* tree_item = item(index);
if (tree_item)
return (index.column() >= 0 ? tree_item->data(index.column(), (Qt::ItemDataRole)role) : QVariant());
else
return QVariant();
if (tree_item != nullptr)
{
int const item_column = mapColumnToItem(index.column(), tree_item->type());
if (item_column >= 0)
{
return tree_item->data(item_column, (Qt::ItemDataRole)role);
}
}

return QVariant();
}

void SignalTreeModel::setCheckedState(SignalTreeItem* item, int index_column)
Expand Down
5 changes: 4 additions & 1 deletion ecal/core/include/ecal/ecal_timed_cb.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ namespace eCAL
{
if (!m_running) return(false);
m_stop = true;
m_thread.join();
// Wait for the callback thread to finish
if (m_thread.joinable()) {
m_thread.join();
}
m_running = false;
return(true);
}
Expand Down
8 changes: 8 additions & 0 deletions ecal/core/include/ecal/msg/capnproto/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ namespace eCAL
{
}

/**
* @brief Destructor
**/
~CBuilderSubscriber() override
{
this->Destroy();
}

/**
* @brief Copy Constructor is not available.
**/
Expand Down
8 changes: 8 additions & 0 deletions ecal/core/include/ecal/msg/flatbuffers/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ namespace eCAL
{
}

/**
* @brief Destructor
**/
~CSubscriber() override
{
this->Destroy();
}

/**
* @brief Copy Constructor is not available.
**/
Expand Down
8 changes: 8 additions & 0 deletions ecal/core/include/ecal/msg/messagepack/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ namespace eCAL
{
}

/**
* @brief Destructor
**/
~CSubscriber() override
{
this->Destroy();
}

/**
* @brief Copy Constructor is not available.
**/
Expand Down
8 changes: 8 additions & 0 deletions ecal/core/include/ecal/msg/protobuf/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ namespace eCAL
{
}

/**
* @brief Destructor
**/
~CSubscriber() override
{
this->Destroy();
}

/**
* @brief Copy Constructor is not available.
**/
Expand Down
8 changes: 8 additions & 0 deletions ecal/core/include/ecal/msg/string/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ namespace eCAL
{
}

/**
* @brief Destructor
**/
~CSubscriber() override
{
this->Destroy();
}

/**
* @brief Copy Constructor is not available.
**/
Expand Down
21 changes: 16 additions & 5 deletions ecal/core/include/ecal/msg/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ namespace eCAL
{
}

virtual ~CMsgSubscriber() = default;

/**
* @brief Copy Constructor is not available.
**/
Expand Down Expand Up @@ -125,8 +127,6 @@ namespace eCAL
return *this;
}

virtual ~CMsgSubscriber() {}

/**
* @brief Creates this object.
*
Expand Down Expand Up @@ -207,7 +207,10 @@ namespace eCAL
assert(IsCreated());
RemReceiveCallback();

m_cb_callback = callback_;
{
std::lock_guard<std::mutex> callback_lock(m_cb_callback_mutex);
m_cb_callback = callback_;
}
auto callback = std::bind(&CMsgSubscriber::ReceiveCallback, this, std::placeholders::_1, std::placeholders::_2);
return(CSubscriber::AddReceiveCallback(callback));
}
Expand All @@ -219,9 +222,12 @@ namespace eCAL
**/
bool RemReceiveCallback()
{
bool ret = CSubscriber::RemReceiveCallback();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'ret' is not initialized [cppcoreguidelines-init-variables]

Suggested change
bool ret = CSubscriber::RemReceiveCallback();
bool ret = 0 = CSubscriber::RemReceiveCallback();


std::lock_guard<std::mutex> callback_lock(m_cb_callback_mutex);
if (m_cb_callback == nullptr) return(false);
m_cb_callback = nullptr;
return(CSubscriber::RemReceiveCallback());
return(ret);
}

protected:
Expand All @@ -245,7 +251,11 @@ namespace eCAL
private:
void ReceiveCallback(const char* topic_name_, const struct eCAL::SReceiveCallbackData* data_)
{
MsgReceiveCallbackT fn_callback(m_cb_callback);
MsgReceiveCallbackT fn_callback = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'fn_callback' is not initialized [cppcoreguidelines-init-variables]

Suggested change
MsgReceiveCallbackT fn_callback = nullptr;
MsgReceiveCallbackT fn_callback = 0 = nullptr;

{
std::lock_guard<std::mutex> callback_lock(m_cb_callback_mutex);
fn_callback = m_cb_callback;
}

if(fn_callback == nullptr) return;

Expand All @@ -256,6 +266,7 @@ namespace eCAL
}
}

std::mutex m_cb_callback_mutex;
MsgReceiveCallbackT m_cb_callback;
};
}
8 changes: 7 additions & 1 deletion ecal/core/src/ecal_registration_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ namespace eCAL
eCAL::pb::Sample modified_ttype_sample;
ModifyIncomingSampleForBackwardsCompatibility(ecal_sample_, modified_ttype_sample);

m_callback_custom_apply_sample(modified_ttype_sample);
// forward all registration samples to outside "customer" (e.g. Monitoring)
{
const std::lock_guard<std::mutex> lock(m_callback_custom_apply_sample_mtx);
m_callback_custom_apply_sample(modified_ttype_sample);
}

std::string reg_sample;
if ( m_callback_pub
Expand Down Expand Up @@ -417,11 +421,13 @@ namespace eCAL

void CRegistrationReceiver::SetCustomApplySampleCallback(const ApplySampleCallbackT& callback_)
{
const std::lock_guard<std::mutex> lock(m_callback_custom_apply_sample_mtx);
m_callback_custom_apply_sample = callback_;
}

void CRegistrationReceiver::RemCustomApplySampleCallback()
{
const std::lock_guard<std::mutex> lock(m_callback_custom_apply_sample_mtx);
m_callback_custom_apply_sample = [](const auto&){};
}
};
10 changes: 10 additions & 0 deletions ecal/core/src/ecal_registration_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ namespace eCAL
CRegistrationReceiver();
~CRegistrationReceiver();

// default copy constructor
CRegistrationReceiver(const CRegistrationReceiver& other) = delete;
// default copy assignment operator
CRegistrationReceiver& operator=(const CRegistrationReceiver& other) = delete;
// default move constructor
CRegistrationReceiver(CRegistrationReceiver&& other) noexcept = delete;
// default move assignment operator
CRegistrationReceiver& operator=(CRegistrationReceiver&& other) noexcept = delete;

void Create();
void Destroy();

Expand Down Expand Up @@ -121,6 +130,7 @@ namespace eCAL
bool m_use_network_monitoring;
bool m_use_shm_monitoring;

std::mutex m_callback_custom_apply_sample_mtx;
ApplySampleCallbackT m_callback_custom_apply_sample;

std::string m_host_group_name;
Expand Down
5 changes: 5 additions & 0 deletions ecal/core/src/ecal_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ namespace eCAL
CThread();
virtual ~CThread();

CThread(const CThread&) = delete;
CThread& operator=(const CThread&) = delete;
CThread(CThread&& rhs) = delete;
CThread& operator=(CThread&& rhs) = delete;

int Start(int period, std::function<int()> ext_caller_);
int Stop();
int Fire();
Expand Down
4 changes: 4 additions & 0 deletions ecal/core/src/ecal_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ namespace eCAL
CTimerImpl(const int timeout_, TimerCallbackT callback_, const int delay_) : m_stop(false), m_running(false) { Start(timeout_, callback_, delay_); }

virtual ~CTimerImpl() { Stop(); }
CTimerImpl(const CTimerImpl&) = delete;
CTimerImpl& operator=(const CTimerImpl&) = delete;
CTimerImpl(CTimerImpl&& rhs) = delete;
CTimerImpl& operator=(CTimerImpl&& rhs) = delete;

bool Start(const int timeout_, TimerCallbackT callback_, const int delay_)
{
Expand Down
5 changes: 4 additions & 1 deletion ecal/core/src/io/ecal_memfile_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ namespace eCAL
{
}

CMemFileThreadPool::~CMemFileThreadPool() = default;
CMemFileThreadPool::~CMemFileThreadPool()
{
Destroy();
}

void CMemFileThreadPool::Create()
{
Expand Down
5 changes: 5 additions & 0 deletions ecal/core/src/io/ecal_memfile_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace eCAL
CMemFileObserver();
~CMemFileObserver();

CMemFileObserver(const CMemFileObserver&) = delete;
CMemFileObserver& operator=(const CMemFileObserver&) = delete;
CMemFileObserver(CMemFileObserver&& rhs) = delete;
CMemFileObserver& operator=(CMemFileObserver&& rhs) = delete;

bool Create(const std::string& memfile_name_, const std::string& memfile_event_);
bool Destroy();

Expand Down
1 change: 1 addition & 0 deletions ecal/core/src/io/snd_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace eCAL
{
if (!m_udp_sender) return(0);

std::lock_guard<std::mutex> const send_lock(m_payload_mutex);
// return value
size_t sent_sum(0);

Expand Down
2 changes: 2 additions & 0 deletions ecal/core/src/io/snd_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include <memory>
#include <mutex>

#include "udp_sender.h"

Expand All @@ -47,6 +48,7 @@ namespace eCAL
SSenderAttr m_attr;

std::shared_ptr<eCAL::CUDPSender> m_udp_sender;
std::mutex m_payload_mutex;
std::vector<char> m_payload;
};
}
5 changes: 5 additions & 0 deletions ecal/core/src/io/udp_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ namespace eCAL
#endif //ECAL_NPCAP_SUPPORT
}

CUDPReceiver::~CUDPReceiver()
{
Destroy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Call to virtual method 'CUDPReceiver::Destroy' during destruction bypasses virtual dispatch [clang-analyzer-optin.cplusplus.VirtualCall]

    Destroy();
    ^
Additional context

ecal/core/src/io/udp_receiver.cpp:58: Call to virtual method 'CUDPReceiver::Destroy' during destruction bypasses virtual dispatch

    Destroy();
    ^

}

bool CUDPReceiver::Create(const SReceiverAttr& attr_)
{
if (m_socket_impl) return false;
Expand Down
6 changes: 6 additions & 0 deletions ecal/core/src/io/udp_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ namespace eCAL
{
public:
CUDPReceiver();
~CUDPReceiver();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: annotate this function with 'override' or (rarely) 'final' [cppcoreguidelines-explicit-virtual-functions]

Suggested change
~CUDPReceiver();
~CUDPReceiver() override;


CUDPReceiver(const CUDPReceiver&) = delete;
CUDPReceiver& operator=(const CUDPReceiver&) = delete;
CUDPReceiver(CUDPReceiver&& rhs) = delete;
CUDPReceiver& operator=(CUDPReceiver&& rhs) = delete;

bool Create(const SReceiverAttr& attr_) override;
bool Destroy() override;
Expand Down
13 changes: 6 additions & 7 deletions ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@ namespace eCAL
* @brief CPublisher are move-enabled
**/
CPublisher::CPublisher(CPublisher&& rhs) noexcept :
m_datawriter(rhs.m_datawriter),
m_datawriter(std::move(rhs.m_datawriter)),
m_qos(rhs.m_qos),
m_tlayer(rhs.m_tlayer),
m_id(rhs.m_id),
m_created(rhs.m_created),
m_initialized(rhs.m_initialized)
{
InitializeQOS();
InitializeTLayer();

rhs.m_created = false;
rhs.m_initialized = false;
}
Expand All @@ -90,15 +88,16 @@ namespace eCAL
**/
CPublisher& CPublisher::operator=(CPublisher&& rhs) noexcept
{
m_datawriter = rhs.m_datawriter;
// Call destroy, to clean up the current state, then afterwards move all elements
Destroy();

m_datawriter = std::move(rhs.m_datawriter);
m_qos = rhs.m_qos;
m_tlayer = rhs.m_tlayer,
m_id = rhs.m_id;
m_created = rhs.m_created;
m_initialized = rhs.m_initialized;

InitializeQOS();
InitializeTLayer();
rhs.m_created = false;
rhs.m_initialized = false;

Expand Down
Loading