【发布时间】:2012-09-03 14:44:56
【问题描述】:
在 Qt Creator (qt 4.8, winxp) 我写的
QuaZip* zipfile = new QuaZip;
zipfile->setZipName("myzipfile.zip");
zipfile->open(QuaZip::mdUnzip);
if(zipfile->isOpen()){
QStringList files = zipfile->getFileNameList();
} // here the error occurs
当文件被销毁时,会显示一个消息框
调试断言失败!
表达式:_CrtIsValidHeapPointer(pUserData)
在调试器中,我有以下函数堆栈:
0 DbgBreakPoint ntdll 0x7c90120e
1 RtlpBreakPointHeap ntdll 0x7c96c201
2 RtlpValidateHeapEntry ntdll 0x7c96c63e
3 RtlValidateHeap ntdll 0x7c9603b0
4 HeapValidate kernel32 0x7c85f8d7
5 _CrtIsValidHeapPointer dbgheap.c 2103 0x102d1ac9
6 _free_dbg_nolock dbgheap.c 1317 0x102d0b3a
7 _free_dbg dbgheap.c 1258 0x102d09e0
8 free dbgfree.c 49 0x102d8990
9 qFree qmalloc.cpp 60 0x5e2f1d
10 QString::free qstring.cpp 1235 0x65dd22
11 QString::~QString qstring.h 880 0x5ac0d3
12 QString::`scalar deleting destructor' QuizSet 0x4120e0
13 QList<QString>::node_destruct qlist.h 433 0x412180
14 QList<QString>::free qlist.h 759 0x4115fb
15 QList<QString>::~QList<QString> qlist.h 733 0x410967
16 QStringList::~QStringList MyApp 0x414d9f
17 MyApp::myFunction myapp.cpp 561 0x420e1c
...
qlist.h 中的第 433 行是调试器停止的位置:
while (from != to) --to, reinterpret_cast<T*>(to)->~T();
仅当我调用 ::getFileNameList() 时才会发生错误,如果我填写列表手册,它工作正常。 quazip的其他操作,我可以解压和压缩数据,只有getFileNameList比较麻烦。
编辑:我找到了原因:我使用的 quazip1.dll 是它的发布版本,只是在调试运行时出现了这个问题。因此,如果我使用调试 quazip.dll,它可以正常工作。恼人的是它们被称为相同的,所以我每次从调试切换到发布时都必须重命名。有人知道解决方法吗?
【问题讨论】:
-
不知道这会如何导致崩溃(甚至编译),但这看起来是错误的:“QuaZip zipfile;”如果里面。您已经将 zipfile 进一步声明为 QuaZip*,因此请删除第二个 zipfile 变量。
-
哦,谢谢,但这只是一个“错字”,我更正了。问题依然存在。
标签: qt destructor quazip