From 5b1b9b5e6cddc6771d63b204c83dee22f09239cb Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 21 Mar 2021 05:44:28 +0300 Subject: [PATCH] fix xml entity key description with escaped characters reading handle special symbols in smartedit key description tooltip --- radiant/eclass_xml.cpp | 9 ++++++++- radiant/entityinspector.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/radiant/eclass_xml.cpp b/radiant/eclass_xml.cpp index 4f281012..d1893360 100644 --- a/radiant/eclass_xml.cpp +++ b/radiant/eclass_xml.cpp @@ -235,7 +235,14 @@ void popElement( const char* elementName ){ ERROR_MESSAGE( PARSE_ERROR( elementName, "attribute" ) ); } std::size_t write( const char* data, std::size_t length ){ - m_attribute->m_description = StringRange( data, data + length ); + CopiedString& desc = m_attribute->m_description; + if( desc.empty() ){ + desc = StringRange( data, data + length ); + } + else{ // in case of special symbols, e.g. ", &apos, <, >, &, xml writes in a few steps + desc = StringOutputStream()( desc.c_str(), StringRange( data, data + length ) ); + } + return m_comment.write( data, length ); } }; diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 8fe53330..112c28c9 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -988,8 +988,11 @@ void EntityAttribute_setTooltip( GtkWidget* widget, const char* name, const char StringOutputStream stream( 256 ); if( string_not_empty( name ) ) stream << " " << name << " "; - if( string_not_empty( description ) ) - stream << "\n" << description; + if( string_not_empty( description ) ){ + gchar *str = g_markup_escape_text( description, -1 ); + stream << "\n" << str; + g_free( str ); + } if( !stream.empty() ) gtk_widget_set_tooltip_markup( widget, stream.c_str() ); }