Michael A. Hess wrote 9 lines
Peter,
I have narrowed it down to the following line. In Dispatch the line that
is determining the number of messages in the table is causing the error.
Let's put it this way that line is were it blows up in xxgdb. :-)
count:=pdword((pdword(...........
This is where it stops in the debugger.
If you got this far, you should have noticed that the vmt was already the vmt of TObject - which has no messages, and hence is a special case.
I added a check to see if there are messages for that class - now the follwing runs fine:
program testdisp;
{$mode objfpc}
type TMyObject = Class(TObject)
Procedure Message1(Var Msg); message 1;
Procedure Message2(Var Msg); message 2;
// Procedure Message3(Var Msg); message 3;
end;
Procedure TMYObject.Message1(Var Msg);
begin
Writeln ('Got message : ',DWord(Msg));
end;
Procedure TMyObject.Message2(Var Msg);
begin
Writeln ('Got message : ',DWord(Msg));
end;
{
Procedure TMyObJect.Message3(Var Msg); message 3;
begin
Writeln ('Got message : ',DWord(Msg));
end;
}
Var MyObject : TMyObject;
Msg : Longint;
begin
MyObject:=TMyObject.Create;
// Run until 3, so a non-registered message is sent.
For Msg:=1 to 3 do
MyObject.Dispatch(Msg);
end.
I've committed this in the RTL.
Could this be related to the same reason that we can't add more than 2
messages to a class definition?
No, because that is a compiler problem, not an RTL problem. So that still needs to be solved.
Michael.