简体   繁体   English

TinyXML++ 的奇怪行为

[英]Odd behavior from TinyXML++

Hoping some of you TinyXML++ people can help me out.希望你们中的一些 TinyXML++ 人可以帮助我。 Really, since you recomended to me before I think you owe me ;)真的,因为你在我认为你欠我之前向我推荐了 ;)

I have the following code:我有以下代码:

   //ticpp::Iterator< ticpp::Element > child( "SetPiece" );
    ticpp::Iterator< ticpp::Node > child("SetPiece");
    GLuint lc_SPieces = 0;
    for(child = child.begin( this ); child != child.end(); child++ )
    {
        lc_SPieces++;
    }

If I use the top declaration for child I get the error:如果我为 child 使用 top 声明,则会收到错误消息:

Unhandled exception at 0x7c812aeb in Drawing.exe: Microsoft C++ exception: __non_rtti_object @ 0x0012f7b4. Drawing.exe 中 0x7c812aeb 处的未处理异常:Microsoft C++ 异常:__non_rtti_object @ 0x0012f7b4。

And I get it in dbgheap.c at this line:我在 dbgheap.c 中的这一行得到了它:

pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine);

What's weird is it works with Node, and I know that there are elements in there(I checked using the TinyXML iteration methods).奇怪的是它适用于 Node,而且我知道那里有元素(我使用 TinyXML 迭代方法进行了检查)。

Has anyone run into this before?有没有人遇到过这个?

just poking in the dark, i don't know tinyxml, but it seems that a dynamic_cast went wrong.只是在黑暗中摸索,我不知道tinyxml,但似乎dynamic_cast 出错了。 If you dynamic_cast<> a pointer, you get a NULL-pointer on failure.如果您使用 dynamic_cast<> 指针,则会在失败时获得 NULL 指针。 However, if you cast to a reference type, there is no concept of a NULL-reference, so the runtime throws this exception (or bad_type).但是,如果您转换为引用类型,则没有 NULL 引用的概念,因此运行时会抛出此异常(或 bad_type)。MSDN on dynamic_cast, and why it can go wrong关于 dynamic_cast 的 MSDN,以及为什么会出错

The line you pasted for the exception to occur does not help to clear up the situation, since it identifies the symptom rather than the cause.您为发生异常而粘贴的行无助于解决问题,因为它识别的是症状而不是原因。

Try to identify the cast that went wrong, you should be able to find it if you walk up the stack and find the last method in tinyxml libs or headers.尝试识别出错的演员表,如果您向上走堆栈并在 tinyxml libs 或 headers 中找到最后一个方法,您应该能够找到它。 Then you can decide whether tinyxml is worng, or you just applied it the wrong way.然后你可以决定tinyxml是否被磨损,或者你只是以错误的方式应用它。

good luck!祝你好运!

__non_rtti_object is generated by the dynamic_cast operator if the passed pointer or reference does not point to a polymorphic object, but to some garbage instead.如果传递的指针或引用不指向多态对象,而是指向一些垃圾,则__non_rtti_object由 dynamic_cast 运算符生成。 Maybe the object had been deleted earlier.也许该对象之前已被删除。

Step through the code in the debugger and check where the dynamic_cast is used and what is passed to it.单步调试调试器中的代码并检查 dynamic_cast 的使用位置以及传递给它的内容。

hth Paavo帕沃

项目 -> 属性 -> C/C++ -> 语言 -> 启用运行时类型信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM