c++ builder:在windows .cpp中访问冲突0x0000002c
C++-builder: access violation 0x0000002c in window.cpp
我正在修改c++ Builder XE2中的程序。该程序还不使用vcl,但使用owlnext。并包含多个MDI-child-forms。
在这里,我使用了一个例程来加载一个文件并打开一个新窗口。
在这个例程中一切工作正常(我在调试模式下一行接一行地跟踪它多次),但是当它完成并且PumpWaitingMessages() // pumps any waiting messages, idleCount=0
再次完成并且TApplication::MessageLoop()
进入下一个循环并调用IdleAction(idleCount++)
调用MainWindow->IdleAction(idleCount)
调用TWindow::IdleAction(idleCount)
这是window.h的函数时,程序崩溃。
在IdleAction中,当调用win->IdleAction(idleCount)
时,应用程序在第一个循环中崩溃,异常:
First chance exception at $004E4CA4. Exception class $C0000005 with message 'access violation at 0x004e4ca4: read of address 0x0000002c'. Process Project2.exe (3772)
函数在Owlnext中定义如下:
//
/// Called when no messages are waiting to be processed, IdleAction performs idle
/// processing as long as true is returned. idleCount specifies the number of times
/// idleAction has been called between messages.
///
/// Propagate idle action to all children if count==0, and to any children that
/// previously said they wanted more time.
//
bool
TWindow::IdleAction(long idleCount)
{
bool wantMore = false;
TWindow* win = GetFirstChild();
if (win) {
do {
if (idleCount == 0 || win->IsFlagSet(wfPropagateIdle)) {
if (win->IdleAction(idleCount)) {
win->SetFlag(wfPropagateIdle);
wantMore = true;
}
else {
win->ClearFlag(wfPropagateIdle);
}
}
win = win->Next();
} while (win && win != GetFirstChild());
}
return wantMore;
}
我的猜测是,有一个无效的句柄的窗口,但win-object似乎并没有无效…我也找不到任何包含0x0000002c地址的变量。
标题和父级为NULL, Handle为0x00000004,但其他值对我来说似乎是合法的…奇怪的是,当检查cursormodule.name时,它告诉我E2122 Function call terminated by unhandled exception 0xc0000005 at address 0x408b1a
那么,有人知道为什么这个错误发生或者我可以做什么或撤消使它正常工作吗?
编辑:Win ->next是定义为
的owl函数//
/// Returns a pointer to the next sibling window in the window's sibling list.
inline TWindow* TWindow::Next()
{
return SiblingList;
}
设置TWindow* SiblingList;
为windows的私有值windows是这样声明的:http://pastebin.com/TzTp4ZXh
你可以检查你是否正确设置了项目设置:有一个整数大小的枚举选项,必须打开结构对齐必须与OWLNext相同——默认为8字节。
另外,您是否可以在启用CodeGuard的情况下构建并查看它是否报告任何问题?
Jogy
所以,我仍然不太清楚这个问题是如何解决的,但由于我计划将其分段移植到vcl,所以我在主文件中加载了#include <vcl.h>
。
我还用owl::TFileSaveDialog(NULL, fileNameData))
替换了所有的TFileSaveDialog(handle, fileNameData))
。
不,没有任何问题了。
- 写入位置0x0000000C时发生访问冲突
- 引发异常:读取访问冲突**dynamicArray**为0x1118235.发生
- 链表中写入访问冲突的未知原因
- C++中的openCV Mat访问冲突
- C++尝试深度复制唯一指针时出现内存访问冲突
- C++ 中动态二维数组的访问冲突
- 从嵌套循环中的 std::list 中删除将返回访问冲突
- 写入访问冲突异常
- 在类 12.exe 中0x7B37FF80 (ucrtbased.dll) 引发异常: 0xC0000005:访问冲突读
- 0xC0000005:访问冲突写入位置0xCDCDCDCD动态分配错误
- 读取访问冲突.这0xCDCDCDCD
- 0xC0000005:访问冲突读取位置 0x00000000. 重载 == 运算符的问题
- 插入数组时违反写访问冲突
- 使用 ReadProcessMemory 获取字符串值的访问冲突
- 尝试通过共享指针使用变量时读取访问冲突
- 堆栈上的 C++ 访问冲突写入异常
- 引发异常:写访问冲突. temp 为 nullptr
- 将静态字符数组中的字符分配给动态分配的字符数组 - 访问冲突
- 在C++中删除双向链表的头节点后出现访问冲突异常
- c++ builder:在windows .cpp中访问冲突0x0000002c