C++-builder : access violation 0x0000002c in window. cpp

标签 c++ c++builder access-violation owlnext

我正在修改 C++ Builder XE2 中的程序。该程序还没有使用 vcl,而是使用了 owlnext。并包含多个 MDI 子窗体。

我使用例程加载文件并打开一个新窗口。

在此例程中一切正常(我在 Debug模式下逐行跟踪它多次),但是当它完成并且 PumpWaitingMessages()//泵送所有等待消息时,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 对象似乎并没有无效...我也找不到任何包含地址 0x0000002c 的变量。

标题和父级为 NULL,句柄为 0x00000004,但其他值对我来说似乎是合法的...但奇怪的是,当检查 cursormodule.name 时,它​​告诉我 E2122 函数调用被未处理的异常终止 0xc0000005在地址 0x408b1a

那么,有人知道为什么会出现此错误,或者我可以执行或撤消哪些操作以使其正常工作吗?

编辑: win->next 是一个猫头鹰函数,定义为

//
/// Returns a pointer to the next sibling window in the window's sibling list.
inline TWindow* TWindow::Next()
{
  return SiblingList;
}

with TWindow* SiblingList; 作为 TWindow 的私有(private) TWindow 声明为:http://pastebin.com/TzTp4ZXh (请点击链接,因为类有一个非常大的声明)

最佳答案

你能检查一下你是否正确设置了项目设置吗: 整数大小的枚举有一个选项,必须打开它 结构对齐方式必须与 OWLNext 中的对齐方式相同 - 默认情况下为 8 个字节。

此外,您能否在启用 CodeGuard 的情况下构建并查看它是否报告任何问题?

欢乐

关于C++-builder : access violation 0x0000002c in window. cpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16190807/

相关文章:

c++ - 异步输入输出/获取前缀后的输入

python - 带索引的 pyOpenGL VBO

c++ - DirectX 11 访问冲突

c++ - 为什么这个双端队列数据结构会引发读取访问冲突

python - 使用命名空间从 C++ 调用 Python 函数

c++ - Eclipse 给出 MingGW 没有的编译器警告

c++ - bcc32 和 bcc32c 对象生命周期的区别

c++ - 通过指针比较

c++ - 使用 C 或 C++ 制作自定义运行对话框?

c++ - 非 const 函数 _fastcall TStrings::GetCount() 为 const 对象调用