Skip to content
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
16 changes: 13 additions & 3 deletions src/plugins/publisher/Publisher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "Publisher.hh"

#include <google/protobuf/text_format.h>

#include <gz/common/Console.hh>
#include <gz/plugin/Register.hh>
#include <gz/transport/Node.hh>

#include "Publisher.hh"
#include <string>

namespace ignition
{
Expand Down Expand Up @@ -125,7 +128,14 @@ void Publisher::OnPublish(const bool _checked)

// Check it's possible to create message
auto msg = msgs::Factory::New(msgType, msgData);
if (!msg || (msg->DebugString() == "" && msgData != ""))

std::string msgToText;
using google::protobuf::TextFormat;
if (msg)
{
TextFormat::PrintToString(*msg, &msgToText);
}
if (!msg || (msgToText.empty() && !msgData.empty()))
{
ignerr << "Unable to create message of type[" << msgType << "] "
<< "with data[" << msgData << "].\n";
Expand Down
18 changes: 14 additions & 4 deletions src/plugins/topic_echo/TopicEcho.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
*
*/

#include <iostream>
#include "TopicEcho.hh"

#include <google/protobuf/text_format.h>

#include <gz/common/Console.hh>
#include <gz/plugin/Register.hh>
#include <gz/transport/Node.hh>
#include <iostream>
#include <string>

#include "gz/gui/Application.hh"
#include "TopicEcho.hh"

namespace ignition
{
Expand Down Expand Up @@ -121,8 +125,14 @@ void TopicEcho::OnMessage(const google::protobuf::Message &_msg)
return;

std::lock_guard<std::mutex> lock(this->dataPtr->mutex);

this->AddMsg(QString::fromStdString(_msg.DebugString()));
if (std::string str; google::protobuf::TextFormat::PrintToString(_msg, &str))
{
emit this->AddMsg(QString::fromStdString(str));
}
else
{
ignerr << "Error printing message" << std::endl;
}
}

/////////////////////////////////////////////////
Expand Down