[fpc-pascal] D-Bus. Non blocking listening for signals
michael.vancanneyt at wisa.be
michael.vancanneyt at wisa.be
Thu Jan 13 15:17:44 CET 2011
On Thu, 13 Jan 2011, dibo20 at 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.
More information about the fpc-pascal
mailing list