0

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

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

在这个例程中一切正常(我在调试模式下逐行跟踪它多次),但是当它完成并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地址的变量。

好吧,title 和 parent 为 NULL,Handle 为 0x00000004,但其他值对我来说似乎是合法的......但奇怪的是,当检查 cursormodule.name 时它告诉我E2122 Function call terminated by unhandled exception 0xc0000005 at address 0x408b1a

那么,有人知道为什么会发生此错误,或者我可以做什么或撤消以使其正常工作吗?

编辑:win->next 是一个定义为的 owl-function

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

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

4

2 回答 2

2

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

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

乔吉

于 2013-04-25T17:19:12.073 回答
0

所以,我仍然不太清楚这是如何详细解决的,但是当我计划将它分段移植到 vcl 时,我加载#include <vcl.h>了主文件。

我也全部替换TFileSaveDialog(handle, fileNameData))owl::TFileSaveDialog(NULL, fileNameData)).

不,没有任何问题了。

于 2013-04-30T12:15:49.533 回答