I am modifying a program in C++ Builder XE2. The program doesn't use vcl yet, but owlnext. and contains multiple MDI-child-forms.
There I use a routine to load a file and open a new window.
Everything works fine in this routine (I traced it multiple times in debug-mode line after line), but when it finishes and PumpWaitingMessages() // pumps any waiting messages, idleCount=0
finishes again and TApplication::MessageLoop()
goes into the next loop and calls IdleAction(idleCount++)
which calls MainWindow->IdleAction(idleCount)
which calls TWindow::IdleAction(idleCount)
which is a function of window.h, the program crashes.
Within IdleAction the Application crashes in the first loop when calling win->IdleAction(idleCount)
with the exception:
First chance exception at $004E4CA4. Exception class $C0000005 with message 'access violation at 0x004e4ca4: read of address 0x0000002c'. Process Project2.exe (3772)
the function is defined in Owlnext like this:
//
/// 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;
}
My guess is that there is an invalid Handle for a window, but the win-object doesn't seem to be invalid... I can also not find any variable containing the address of 0x0000002c.
Well title and parent is NULL and Handle is 0x00000004, but the other values seem legit to me... A strange thing though is when checking the cursormodule.name it tells me E2122 Function call terminated by unhandled exception 0xc0000005 at address 0x408b1a
So, does somebody knows why this error occurs or what I can do or undo to make it work correctly?
Edit: win->next is an owl-function defined as
//
/// Returns a pointer to the next sibling window in the window's sibling list.
inline TWindow* TWindow::Next()
{
return SiblingList;
}
with TWindow* SiblingList;
as private of TWindow
TWindow is declared as this: http://pastebin.com/TzTp4ZXh
(please follow the link as the class has a very large declaration)
can you check if you have correctly set up the project settings: There is an option for integer-sized enums, it must be turned on The structures alignment must be same as in the OWLNext - which by default is 8 bytes.
Also, can you build with CodeGuard enabled and see if it reports any problems?
Jogy
So, I still don't have much clue how this was solved in detail, but as I plan to port it piecewise to vcl, I loaded #include <vcl.h>
in the main file.
I also replaced all TFileSaveDialog(handle, fileNameData))
with owl::TFileSaveDialog(NULL, fileNameData))
.
And no there aren't any problems anymore.
User contributions licensed under CC BY-SA 3.0