l10ntools/source/xmlparse.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
New commits: commit e735de2051143347b7283c85ad80b0e2412522dc Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Sun Nov 20 17:46:31 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Sun Nov 20 22:39:54 2022 +0100 Avoid some unnecessary, wrong downcasts during `make translations` > l10ntools/source/xmlparse.cxx:491:51: runtime error: downcast of address 0x603000000610 which does not point to an object of type 'XMLParentNode' > 0x603000000610: note: object is of type 'XMLDefault' > 00 00 00 00 30 44 a7 dd a0 55 00 00 00 05 10 6e a4 7f 00 00 80 00 00 00 60 60 00 00 00 00 00 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'XMLDefault' > #0 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:491:51 > #1 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:481:9 > #2 in HelpParser::CreatePO(rtl::OString const&, rtl::OString const&, XMLFile*, std::basic_string_view<char, std::char_traits<char>>) at l10ntools/source/helpmerge.cxx:91:20 > #3 in sal_main_with_args(int, char**) at l10ntools/source/helpex.cxx:124:17 > #4 in main at l10ntools/source/helpex.cxx:47:1 and > l10ntools/source/xmlparse.cxx:523:44: runtime error: downcast of address 0x6030000007c0 which does not point to an object of type 'XMLParentNode' > 0x6030000007c0: note: object is of type 'XMLData' > 00 00 00 00 e0 53 d5 c0 46 56 00 00 d0 00 00 00 40 60 00 00 f0 07 00 00 30 60 00 00 00 00 00 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'XMLData' > #0 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:523:44 > #1 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:492:80 > #2 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:481:9 > #3 in HelpParser::CreatePO(rtl::OString const&, rtl::OString const&, XMLFile*, std::basic_string_view<char, std::char_traits<char>>) at l10ntools/source/helpmerge.cxx:91:20 > #4 in sal_main_with_args(int, char**) at l10ntools/source/helpex.cxx:124:17 > #5 in main at l10ntools/source/helpex.cxx:47:1 and > l10ntools/source/xmlparse.cxx:526:48: runtime error: downcast of address 0x603000000820 which does not point to an object of type 'XMLParentNode' > 0x603000000820: note: object is of type 'XMLComment' > 00 00 00 00 28 06 92 a9 17 56 00 00 d0 00 00 00 40 60 00 00 40 00 00 00 20 61 00 00 00 00 00 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'XMLComment' > #0 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:523:44 > #1 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:492:80 > #2 in XMLFile::CheckExportStatus(XMLParentNode*) at l10ntools/source/xmlparse.cxx:481:9 > #3 in HelpParser::CreatePO(rtl::OString const&, rtl::OString const&, XMLFile*, std::basic_string_view<char, std::char_traits<char>>) at l10ntools/source/helpmerge.cxx:91:20 > #4 in sal_main_with_args(int, char**) at l10ntools/source/helpex.cxx:124:17 > #5 in main at l10ntools/source/helpex.cxx:47:1 Change-Id: I1e2c6bf802aa03b5b1eb21532e98fa22d966e683 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143000 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index b32ed4f5037a..bcf5d37154cb 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -488,8 +488,8 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur ) { for ( size_t i = 0; i < GetChildList()->size(); i++ ) { - XMLParentNode* pElement = static_cast<XMLParentNode*>((*GetChildList())[ i ]); - if( pElement->GetNodeType() == XMLNodeType::ELEMENT ) CheckExportStatus( pElement );//, i); + XMLChildNode* pElement = (*GetChildList())[ i ]; + if( pElement->GetNodeType() == XMLNodeType::ELEMENT ) CheckExportStatus( static_cast<XMLParentNode*>(pElement) );//, i); } } } @@ -520,7 +520,13 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur ) else if ( pElement->GetChildList() ) { for (size_t k = 0; k < pElement->GetChildList()->size(); ++k) - CheckExportStatus( static_cast<XMLParentNode*>((*pElement->GetChildList())[k]) ); + { + auto const child = (*pElement->GetChildList())[k]; + auto const type = child->GetNodeType(); + if (type != XMLNodeType::DATA && type != XMLNodeType::COMMENT) { + CheckExportStatus( static_cast<XMLParentNode*>(child) ); + } + } } } break;