W dniu 13.01.2011 15:17, michael.vancann...@wisa.be pisze:


On Thu, 13 Jan 2011, dib...@wp.pl wrote:

This code work too:

TMyObj = class
private
procedure EventProc(AData: PtrInt; AFlags: dword);
end;

var
Sock: cint;
p: PEventHandler;

const
GLIB_SYSDEF_POLLIN = 1;
GLIB_SYSDEF_POLLOUT = 4;
GLIB_SYSDEF_POLLPRI = 2;
GLIB_SYSDEF_POLLERR = 8;
GLIB_SYSDEF_POLLHUP = 16;
GLIB_SYSDEF_POLLNVAL = 32;

ALL_FLAGS = GLIB_SYSDEF_POLLIN or GLIB_SYSDEF_POLLPRI or
GLIB_SYSDEF_POLLERR or GLIB_SYSDEF_POLLHUP or GLIB_SYSDEF_POLLNVAL;

implementation

{ TMyObj }

procedure TMyObj.EventProc(AData: PtrInt; AFlags: dword);
begin
BusReceive;
end;

....
begin
dbus_connection_get_socket(conn, @Sock);
p := AddEventHandler(Sock, ALL_FLAGS, @EventProc, 0);
end;

If you refer here to TMyObj.EventProc, then that code is wrong:
the stack will get confused. I'm surprised it compiles at all.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

This is only example fragment. Of course I refer to the object method by MyObj.EventProc, not to the class. I just wanted to show you how I get socket handle.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to