File tree Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Original file line number Diff line number Diff line change 15
15
*
16
16
*/
17
17
18
- #include < gz/utils/ImplPtr.hh>
19
- #include < iostream>
18
+ #include " Publisher.hh"
19
+
20
+ #include < google/protobuf/text_format.h>
21
+
20
22
#include < gz/common/Console.hh>
21
23
#include < gz/msgs/Utility.hh>
22
24
#include < gz/plugin/Register.hh>
23
25
#include < gz/transport/Node.hh>
24
-
25
- #include " Publisher.hh "
26
+ # include < gz/utils/ImplPtr.hh >
27
+ #include < string >
26
28
27
29
namespace gz ::gui::plugins
28
30
{
@@ -107,7 +109,14 @@ void Publisher::OnPublish(const bool _checked)
107
109
108
110
// Check it's possible to create message
109
111
auto msg = msgs::Factory::New (msgType, msgData);
110
- if (!msg || (msg->DebugString ().empty () && !msgData.empty ()))
112
+
113
+ std::string msgToText;
114
+ using google::protobuf::TextFormat;
115
+ if (msg)
116
+ {
117
+ TextFormat::PrintToString (*msg, &msgToText);
118
+ }
119
+ if (!msg || (msgToText.empty () && !msgData.empty ()))
111
120
{
112
121
gzerr << " Unable to create message of type[" << msgType << " ] "
113
122
<< " with data[" << msgData << " ].\n " ;
Original file line number Diff line number Diff line change 15
15
*
16
16
*/
17
17
18
- #include < gz/utils/ImplPtr.hh>
19
- #include < iostream>
18
+ #include " TopicEcho.hh"
19
+
20
+ #include < google/protobuf/text_format.h>
21
+
20
22
#include < gz/common/Console.hh>
21
23
#include < gz/plugin/Register.hh>
22
24
#include < gz/transport/Node.hh>
25
+ #include < gz/utils/ImplPtr.hh>
26
+ #include < iostream>
27
+ #include < string>
23
28
24
29
#include " gz/gui/Application.hh"
25
- #include " TopicEcho.hh"
26
30
27
31
namespace gz ::gui::plugins
28
32
{
@@ -109,8 +113,14 @@ void TopicEcho::OnMessage(const google::protobuf::Message &_msg)
109
113
return ;
110
114
111
115
std::lock_guard<std::mutex> lock (this ->dataPtr ->mutex );
112
-
113
- emit this ->AddMsg (QString::fromStdString (_msg.DebugString ()));
116
+ if (std::string str; google::protobuf::TextFormat::PrintToString (_msg, &str))
117
+ {
118
+ emit this ->AddMsg (QString::fromStdString (str));
119
+ }
120
+ else
121
+ {
122
+ gzerr << " Error printing message" << std::endl;
123
+ }
114
124
}
115
125
116
126
// ///////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments