我正在修改C++生成器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地址的变量。
Well title和parent为空,句柄为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的私有TWindow* SiblingList;时,TWindow声明为:http://pastebin.com/TzTp4ZXh (请跟随链接,因为该类有一个非常大的声明)
发布于 2013-04-30 20:15:50
所以,我仍然没有太多的线索来详细地解决这个问题,但是当我计划将它分段移植到vcl时,我在主文件中加载了#include <vcl.h>。
我还用owl::TFileSaveDialog(NULL, fileNameData))替换了所有的TFileSaveDialog(handle, fileNameData))。
不会再有任何问题了。
发布于 2013-04-26 01:19:12
您是否可以检查是否正确设置了项目设置:有一个用于整数大小枚举的选项,必须打开它,结构对齐方式必须与OWLNext中的相同-默认情况下为8字节。
此外,您是否可以在启用CodeGuard的情况下进行构建,并查看它是否报告任何问题?
Jogy
https://stackoverflow.com/questions/16190807
复制相似问题