c++ - 调用 QDomElement::text() 函数时出现 Visual Studio 2008 "Debug Assertion Failed"消息

标签 c++ visual-studio-2008 qt qtxml

我已经包含了源代码、错误和堆栈跟踪。我该如何解决这个问题?我需要关于如何进行的指示(解释)

源代码:

QFile xmlInputFile(".\\gatewayipmonitor.xml");  
xmlInputFile.open(QIODevice::ReadOnly);

QByteArray xmlData(xmlInputFile.readAll());

QDomDocument doc;
doc.setContent(xmlData);

QDomElement docEl(doc.documentElement());
const QString tagName(docEl.tagName());

docEl.text();

当最后一行被执行时——我收到消息

Windows has triggered a breakpoint in tests.exe.

This may be due to a corruption of the heap, which indicates a bug in tests.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while tests.exe has focus.

The output window may have more diagnostic information. "

当我点击继续 - 我进一步收到消息 -

Program: ...n\tests\Release\tests.exe File: f:\dd\vctools\crt_bld\self_x86\crt\dbgheap.c

Expression:_CrtIdValidHeapPointer(pUserData)

堆栈跟踪:

msvcr90d.dll!_free_dbg_nolock(void * pUserData=0x00a5f348, int nBlockUse=1)  Line 1317 + 0x30 bytes C++
msvcr90d.dll!_free_dbg(void * pUserData=0x00a5f348, int nBlockUse=1)  Line 1258 + 0xd bytes C++
msvcr90d.dll!free(void * pUserData=0x00a5f348)  Line 49 + 0xb bytes C++
QtCored4.dll!qFree(void * ptr=0x00a5f348)  Line 60 + 0xa bytes  C++
QtCored4.dll!QString::free(QString::Data * d=0x00a5f348)  Line 1185 + 0x9 bytes C++
QtCored4.dll!QString::~QString()  Line 883 + 0x23 bytes C++
tests.exe!test_GatewayIpMonitor()  Line 321 + 0xc bytes C++
tests.exe!main()  Line 343  C++
tests.exe!__tmainCRTStartup()  Line 586 + 0x17 bytes    C

最佳答案

我在发布版本中运行该程序,但链接到调试构建库 (Qtcored.lib)。这就是问题所在。

关于c++ - 调用 QDomElement::text() 函数时出现 Visual Studio 2008 "Debug Assertion Failed"消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6750424/

相关文章:

c# - Visual Studio 格式化问题

c - 在 VS2008 中使用 C 语言处理 .txt

qt - 如何在Qt中将一个小部件放置在另一个上

c++ - Qt 对象/类到 Qt ui 文件

c++ - Qt 从派生类发出基类信号

c++ - 实现自定义 Gtkmm 小部件 : what should I return in the virtual on_* functions?

c++ - Boost::Python: 没有找到 C++ 类型的转换器:boost::python::detail::kwds_proxy

c# - 同一项目,不同机器,一台机器存在交叉线程问题

C++ + 运算符的这种用法叫什么?目的是什么?

c++ - 使用 dlsym 访问类符号